0

I am using the 2.3.1.min version of the jquery-jsonp library found here: https://github.com/jaubourg/jquery-jsonp and it works as expected, namely the error function fires when an error occurs. However, I cannot to seem to display the error encountered. I checked the docs on github project but could not find an answer.

Is this a limitation? Or am I not calling the right object?

My implementation..

The url parameter below is set to return a 404 page on purpose. Chrome dev tools shows a 404 response, but I cannot seem to capture that result..

    <script type="text/javascript">
        $.jsonp({
                url: 'http://apps.mydomain.com/Service/NonExistant?&max=4&format=json',
                callbackParameter: "callback",
                error: function(xOptions, textStatus){ 
                    // this lines returns "error"
                    console.log(textStatus); 

                    // this returns the Object (but expanding it reveals no indication of error code / message)
                    console.log(xOptions);
                },
                success: function(json, textStatus) {
                    Populate(json); // this works fine
                }
            });
    </script>
robnardo
  • 921
  • 11
  • 27

1 Answers1

0

Sadly, you can't. Johnny Wey explains it far better than I could - but essentially, it's relying on a "script" tag to get the JSON response, rather than a request executed via javascript.

You could wrap the type of error within the JSONP response per Parsing JSONP Response in Javascript when 4xx or 5xx Http Error Code is Present, but that still won't help you with a 404 error.

Unfortunately, though JSONP error handling is effectively non-existent. The "Cautionary Note" from IBM specifically mentions that "First and foremost, there is no error handling for JSONP calls".

Community
  • 1
  • 1
Pete - MSFT
  • 4,249
  • 1
  • 21
  • 38