- Node.js(エクスプレス)Webサーバー
- Webサーバーのリクエストハンドラ
app.get('/documents/ajax/:id.:format?', function(req, res) { console.log ('Request Received'); var body = 'hello world'; res.writeHead(200, { 'Content-Length': body.length, 'Content-Type': 'text/plain' }); })
- クライアント側のJavaScriptからのajaxリクエスト
$.ajax({ url : "/documents/ajax/" + item, success : function(msg) { alert ("success" + msg); }, error : function(request, status, error) { alert("Error, returned: " + request); alert("Error, returned: " + status); alert("Error, returned: " + error); } });
- サーバー側でリクエストを受信でき、4つのリクエストを送信します
しかし、私の成功イベントはクライアント側のJSで呼び出されていません。また、Webサーバーを停止すると、エラーハンドラーが呼び出されるのがわかります。
助けてください。