teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

2

this統一

2016/03/14 18:40

投稿

mpyw
mpyw

スコア5223

answer CHANGED
@@ -58,17 +58,17 @@
58
58
  var xhr = new XMLHttpRequest;
59
59
  xhr.open('get', '/api/execute_shellcommand.php', true);
60
60
  xhr.onreadystatechange = function () {
61
- if (xhr.status === 200 && this.readyState === 3) {
61
+ if (this.status === 200 && this.readyState === 3) {
62
62
  // chunkの一部分が返ってきたときテキストエリアを更新
63
63
  area.textContent = this.responseText;
64
64
  return;
65
65
  }
66
- if (xhr.status === 200 && this.readyState === 4) {
66
+ if (this.status === 200 && this.readyState === 4) {
67
67
  // 終了時
68
68
  start.disabled = false;
69
69
  return;
70
70
  }
71
- if (xhr.status !== 200 && this.readyState === 4) {
71
+ if (this.status !== 200 && this.readyState === 4) {
72
72
  // エラー時
73
73
  alert('エラー!');
74
74
  start.disabled = false;

1

補足

2016/03/14 18:40

投稿

mpyw
mpyw

スコア5223

answer CHANGED
@@ -85,5 +85,6 @@
85
85
 
86
86
  ```
87
87
 
88
- 一応実装例があるのでこちらに貼っておきます
88
+ **Apacheとか`php -S`に頼らず全てWebサーバまでPHPで実装した**例があるのでこちらに貼っておきます
89
+ (あんまり参考にならないかも)
89
90
  [https://github.com/mpyw/http-tutorial-with-php](https://github.com/mpyw/http-tutorial-with-php)