javascript - JSONP responseText on http error -



javascript - JSONP responseText on http error -

i using jsonp ajax request jquery send data. when info not processed reason, homecoming result http status other 200. way can utilize access logs parse them statistics.

unfortunately, don't response when status code not 200, although jquery callback in response body (when check firebug). there way grab response?

class="lang-js prettyprint-override">$.ajax({ type: 'get', url: '{{ sendmsgurl }}', async: false, data: { 'form': formdata }, datatype: 'jsonp', success: function(json2) { if (json2.status == 'ok') // stuff else { // output error }; }, error: function(xhr, status, error) { // doesn't work: never gets here alert(xhr.responsetext); var json2 = eval("("+xhr.responsetext+")"); } }).fail(function(jqxhr) { // never gets here either alert('status '+jqxhr.responsejson); });

no. jsonp doesn't utilize xhr. injects <script> element page.

in theory, might able find error event handler script, won't fire cross-origin requests (and there isn't much point in using jsonp unless making cross-origin request).

you'll never details of http response headers in event handler when using jsonp.

javascript jquery ajax jsonp

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -