I am implementing an application that relies on communication between a JavaScript client and a server that knows how to respond to the client using JSONP notation.
I am trying to handle a case in my Javascript client where my server is returning with a status code of http 4xx or 5xx. Currently, I see that the script is not being evaluated, because the browser believes that this is an error (as it is.) However, I still want to read what my server should say in this case 4xx or 5xx in my JavaScript client.
I see that this is causing an error in the script tag element, but I am concerned that this is not a cross browser and will not be a reliable solution.
Did anyone still manage to parse the jsonp response, even if the http status code is 4xx or 5xx?
I am starting to believe that I should just use this “set timeout” solution, which “detects” a failure by indicating the callback function to the jsonp request, will be completed within a certain period of time, and if it is not, an error has occurred.
EDIT: I temporarily return a 200 status code when my server detects a jsonp client and then tunnels the error message / status in the returned json object. I was hoping to use HTTP status codes, but I think this is not for the javscript client.
Macy abbey
source share