Perl Webフレームワークでいくつかのajaxを構築してDancer
いますが、他の方法では成功したリクエストのように見えるものからjQueryのajax成功ハンドラーをトリガーできないため、適切なhttpヘッダーで応答しているかどうかはわかりません。以下のajaxスニペットを使用すると、ブラウザーコンソールに次の出力が表示されます。完全なコールバックが正常に呼び出され、正常な出力のように見えます。Status:200 StatusText:"OK"
ただし、成功ハンドラーが呼び出されることはありません。
$.ajax({type: "GET", url: "/learn/faq",
success: function(data){console.log('omg got it');},
complete: function(data){console.log("complete", data);}
}).success(function(data){console.log('defered');});
Object
XHR finished loading: "https://www.localhost:4443/learn/faq". assets-d36e1bb9fd59ba3dbd0f8a0cbb37ed8e.js:1
complete
Object {readyState: 4, responseText: "↵↵<!DOCTYPE html>↵<html xmlns="http://www.w3.org/1…ead/conversion.js"></script>↵↵↵↵</body>↵</html>↵↵", status: 200, statusText: "OK"
omg got it
とdefered
メッセージが表示されるはずですが、表示されません。これを見ると、jQueryの成功ハンドラーにはステータスよりも多くのものがあり、Dancerhttpの実装が正しく応答していないように感じます。
さらにerror
、スニペットにハンドラーを追加したところ、リクエストが成功したように見えるエラーハンドラーがトリガーされています。
$.ajax({type: "GET", url: "/learn/faq",
success: function(data){console.log('omg got it');},
complete: function(data){console.log("complete", data);},
error: function(data){console.log("error!", data);}
}).success(function(data){console.log('defered');});
Object
XHR finished loading: "https://www.localhost:4443/learn/faq". assets-8cd028b93e0db9dd9455125dc98d5ae1.js:1
error!
Object {readyState: 4, responseText: "↵↵↵↵↵↵↵↵↵↵↵↵↵↵↵↵<!DOCTYPE html>↵<html xmlns="http:…></script>↵↵↵↵</body>↵</html>↵↵↵↵</body>↵</html>↵", status: 200, statusText: "OK"}
complete
Object {readyState: 4, responseText: "↵↵↵↵↵↵↵↵↵↵↵↵↵↵↵↵<!DOCTYPE html>↵<html xmlns="http:…></script>↵↵↵↵</body>↵</html>↵↵↵↵</body>↵</html>↵", status: 200, statusText: "OK"}
これがからの応答ヘッダーですjQuery getAllResponseHeaders()
complete Date: Tue, 01 Jan 2013 22:43:52 GMT
Content-Encoding: gzip
X-Powered-By: Perl Dancer 1.3095.1
Transfer-Encoding: chunked
Connection: keep-alive
Server: nginx/1.2.4
Strict-Transport-Security: max-age=2592000
Content-Type: text/xml; charset=utf-8