There is a remote server (on the client machine) that accepts requests of only a certain format, if you use the jQuery dataType: JSONP as an example. Otherwise, requests are rejected as cross-browser.

However, the server accepts the following request:

<script type="text/javascript"> $.ajax({ url: "http://site.com:6898/server/api", jsonp: "callback", dataType: "jsonp", data: { method: "get_token", }, success: function( response ) { console.log("success:");console.log(response ); } error: function( xhr, status, error ) { console.log("error:"); console.log(JSON.stringify(xhr) ); }, complete: function (xhr, textStatus){ console.log( "complete: " + JSON.stringify(xhr)+" "+ textStatus); } }); </script> 

The key here is dataType: "jsonp". If you specify any other type, the request is rejected, as cross-domain, prohibited by the north.

However, due to the special JSONP specification, the response (RAW body) is as follows:

 {"result": {"token": "85973778790d3f951631a6406d9186b758048bbcb0e56b2f73bb5ed23720a705"}, "error": null} 

Thus, the browser is not able to process such an answer, because no name for callback function, and returns an error: SyntaxError: missing; before statement

In the console, processed responses ERROR: {"readyState": 4, "status": 200, "statusText": "load"} COMPLETE (textStatus): parsererror

Everything is logical. The browser cannot parse JSONP, because curve format. However, the only way the server responds.

Question: how is it possible to pick up the RAW answer (body)?

    0