Please consider the following JavaScript
$.ajax({
url: 'http://www.example.com/jsfunc/mycallback',
cache: true,
dataType: 'jsonp',
jsonp: false, // defined by jsfunc/ argument
jsonpCallback: "mycallback",
timeout: 10000,
error: function(jqXHR, textStatus, errorThrown) {
window.console.log('JSONP Error: ' + textStatus + ' ' + errorThrown);
},
complete: function(jqXHR, textStatus) {
window.console.log('JSONP was retrieved successfully');
}
});
window.mycallback = function(data) {
window.console.log('Callback with ' + data);
}
In standard operation the URL is requested, mycallback hit and the complete function run.
The problem I have is on occasion the URL returns data that triggers the error parsererror mycallback was not called. I'd like to log the data that is returned, obviously this data does not contain mycallback({[...]}) as the callback has not been triggered. As the situation only occurs on occasion under heavy load and I don't know what the data is the service is returning I'd like to log it so I can debug it.
I've looked at jqXHR.responseText and jqXHR.responseXML and both these are empty.
If the data returned by a jQuery JSONP request doesn't call the callback how can it be retrieved?
Many thanks in advance,
Pete