0

I have a problem. I'm using $.ajaxError for global error handling in ajax requests. Somehow a $.post request is throwing the error, the status is 200. Why is it causing the error ? Could someone explain me the usage of $.ajaxError ?

Thanks

There is the code:

$('#haha').ajaxError(function(e, jqXHR, settings, exception) {

console.log(jqXHR.status);
console.log(exception.message);

});

EDIT

I have set the header to JSON, and the response was text. :)

litenull
  • 317
  • 1
  • 4
  • 11
  • What does the message say ? – MD Sayem Ahmed Dec 06 '12 at 08:37
  • Just a moment. I will copy the message. – litenull Dec 06 '12 at 08:39
  • I couldnt get the exception message. Somehow it is giving me the native code response in Javascript. Has the exception parameter changed in jQuery 1.8 ? I have the responseText. It is giving me the response from the server: 'SERVERRESPONSE'. So, the code is 200, the reponse is ok, why is it throwing the error ? In the meantime im going to give you the exception. – litenull Dec 06 '12 at 08:55
  • do you have a live example? – devnull69 Dec 06 '12 at 08:55
  • I couldnt because the web service is not public. However, the exception is:'Unexpected token d'. The first word of the response is 'd'. What is going on ? – litenull Dec 06 '12 at 09:03
  • I found the error. I have set the header JSON and the response was text. :) – litenull Dec 06 '12 at 09:13
  • Hint: http://stackoverflow.com/questions/6186770/ajax-request-return-200-ok-but-error-event-is-fired-instead-of-success/6186905#6186905 – Salman A Dec 06 '12 at 09:22

0 Answers0