I'm having trouble debugging why an AJAX request is failing. So far I have this as my error handler:
- "AJAXerrorHandler" : function(jqXHR, textStatus, errorThrown){
- $('body').prepend('Error: <ul>'+
- '<li>textStatus: '+textStatus+'</li>'+
- '<li>errorThrown: '+errorThrown+'</li>'+
- '<li>jqXHR.status: '+jqXHR.status+'</li>'+
- '<li>jqXHR.statusText: '+jqXHR.statusText+'</li>'+
- //'<li>jqXHR.responseText: '+jqXHR.responseText+'</li>'+
- '</ul>');
- },
and am making the request like so:
- $.ajax({ "url": this.href+'&format=json',
- "dataType": "json",
- "success": function(page){return function(data){dk.ge.createClusterInfoWindow(data, page, true);};}(page),
- "error" : dk.ge.AJAXerrorHandler
- }
- );
The request is made successfully and a response returned from the server, but the error handler is called rather than the success handler.
For the error in question, this prints:
Error:- textStatus: error
- errorThrown:
- jqXHR.status: 0
- jqXHR.statusText: error
Printing jqXHR.responseText to the page shows that jquery has received the response OK, though it is difficult to see exactly what jqXHR.responseText contains as it has some html in it, which is converted to html when printed rather than being displayed as plain text.
Using Fiddler to debug the request, the headers of the response are:
- HTTP/1.1 200 OK
- Server: nginx/0.7.64
- Date: Wed, 30 Nov 2011 17:04:22 GMT
- Content-Type: application/json
- Connection: keep-alive
- X-Powered-By: PHP/5.3.4
- Vary: Accept-Encoding
- Cache-Control: private, must-revalidate
- Content-Length: 21593
and the response body validates as valid JSON using
http://jsonlint.com/, so I can't work out why the AJAX request is 'failing'.
Is there any way I can get more info on what the actual error is?