json - How to retrieve error message from xOptions in jquery-jsonp library -
i using 2.3.1.min version of jquery-jsonp library found here: https://github.com/jaubourg/jquery-jsonp , works expected, namely error function fires when error occurs. however, cannot seem display error encountered. checked docs on github project not find answer.
is limitation? or not calling right object?
my implementation..
the url parameter below set return 404 page on purpose. chrome dev tools shows 404 response, cannot seem capture result..
<script type="text/javascript"> $.jsonp({ url: 'http://apps.mydomain.com/service/nonexistant?&max=4&format=json', callbackparameter: "callback", error: function(xoptions, textstatus){ // lines returns "error" console.log(textstatus); // returns object (but expanding reveals no indication of error code / message) console.log(xoptions); }, success: function(json, textstatus) { populate(json); // works fine } }); </script>
sadly, can't. johnny wey explains far better - essentially, it's relying on "script" tag json response, rather request executed via javascript.
you wrap type of error within jsonp response per parsing jsonp response in javascript when 4xx or 5xx http error code present, still won't 404 error.
unfortunately, though jsonp error handling non-existent. "cautionary note" ibm mentions "first , foremost, there no error handling jsonp calls".
Comments
Post a Comment