Request callback status "textStatus"

The following code works fine, but the only problem is not giving me textStatus. What do I need to do to receive textStatus?

 var url = "http://host/MyServiceImpl.svc/GetCount?method=?";
        $.ajax({  
            dataType: 'jsonp',
            data: { Id: '1' },  
            jsonp: 'jsonp_callback',  
            url: url,  
            success: function (json, textStatus) {
                alert(json.d);
                alert(textStatus);
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                debugger
            }
        });

or

$.getJSON(url, { Id: '1'},
  function (data, textStatus) {
         alert(textStatus);
});
+3
source share
1 answer

JsonP works by writing a tag to your document with the destination URL as the source. The server then completes the response in the function call.

somecallback( your data )  

The disadvantage of this is that XMLHttpRequest is not used and therefore is not a "real" errordetection for jsonP. So basically this will not work, because jsonP is a hack in itself.

, , , . json .Success .ErrorMessage. :

{ Success: true|false, ErrorMessage: "", Data:json}   

of the course 404 500 , jsonP.

+1

Source: https://habr.com/ru/post/1776491/


All Articles