22

I have a web application that crashes on ajax requests with google chrome (it works with every other web browser it was tested it). After debugging I found that the error is caused by response.responseText being undefined. The xhr object looks like this:

argument: undefined
isAbort: false
isTimeout: undefined
status: 0
statusText: "communication failure"
tId: 3

In debugger in the 'network' tab I get "(failed)", however all the headers are there and I can even copy into clipboard the response body (which is a valid JSON).

My question is - how can I debug this problem? Where to find additional information, what causes this request to fail?

zefciu
  • 1,967
  • 2
  • 17
  • 39
  • Please, provide more info on the server and network infrastructure. Does the error occur every time you issue the request or sporadically? – Stan Dec 17 '12 at 19:05
  • Can you show how you are doing the AJAX call? Also, can you please tell in which browsers it is working? – Uooo Feb 12 '13 at 07:02
  • Are you not receiving any errors within the JavaScript console? –  Feb 17 '13 at 01:44
  • What say this error? Can you paste error message here? – WooCaSh Feb 17 '13 at 12:03

2 Answers2

13

I finally found the solution to my problem : AdBlocks, when it blocks an ajax request, it just says "communication failure".

Korri
  • 657
  • 7
  • 22
  • 3
    THANK YOU for pointing this out. Spent the better of the afternoon banging my head over this. – applepie Jul 10 '13 at 00:41
  • 1
    thanks , you saved my day ! adBlocks prevents ajax requests such as ads/add ... excluding domain from adBlocks solved my problem ! – Shahrokhian Jan 11 '14 at 17:59
4

The first thing I would double-check is that the data coming back from the response is valid JSON. Just pass it through a JSON validator like this online JSONLint: http://jsonlint.com/

I assume that you are using something like jQuery to make your AJAX requests. If so, then make sure that you are using the development version of that library. Now that you are using the development version (uncompressed) of the script, find the particular function that you are using (eg. $.ajax) and then, within the Chrome inspector, insert a breakpoint in the code where the AJAX response is first handled (eg. https://github.com/jquery/jquery/blob/master/src/ajax.js#L579). Then proceed to step through the code, inspecting various return-values to see exactly what is going wrong.

If you are not using something like jQuery to make AJAX calls, then I'd recommend using a framework to avoid possible cross-browser compatibility issues like you might be experiencing right now.

  • I'm not sure if this is the correct fix, as it was long time ago, but I didn't think the invalid json could be a reason to display the request as failed. So I accept your anwer hoping that if I encounter this in the future, it would be helpful. – zefciu Feb 17 '13 at 14:14