Parsing JSONP Response in Javascript when 4xx or 5xx Http Error Code is Present -


I'm implementing an application that depends on the communication between the JavaScript client and a server who knows JSONP Notation

I am trying to handle the issue in my Javascript client where my server returns an HTA status code with 4xx or 5xx, what I am currently seeing is that the script is not evaluated Because the browser believes that this is an error (which is this). However, I still want to read this code of 4xx or 5xx of this server in my Javascript client code.

I think this script generates an error on the tag element, but I'm worried that it is not a cross browser and it will not be a strong solution.

Does anyone have any luck to parse jsonp response, however, the http status code is 4xx or 5xx?

I believe that I should use this "Set timeout" solution which detects failure by telling callback function on jsonp request, will be completed within a set time frame, and if it does not So, there was an error.

Edit: I am temporarily returning 200 status codes when my server detects a jsonp client and then tunnels the error message / status in the Jason object. I was hoping to take advantage of the HTTP status code, but I'm thinking that there is no one for Javascript client.

An approach when using the JSONP to embed the position information located in the callback, the callback function

This looks like your call appears

  http : //myurl.com/? Callback = fn   

Generate code for a successful call that

  fn ({"data": "my Great data "}, 200)   

and an extraordinary condition

  fn (null, 500," server error ")    

Comments