Handle Errors with jquery ajax call and JSONP dataType

How to deal with the errors using JSONP

by Mikeldi Cesteros

JavaScript

$.ajax({
    url: "google.com/api/doesnotexists",
    dataType: "jsonp",
    timeout: 5000,

    success: function (parsed_json) {
    console.log(parsed_json);
    },

    error: function (parsedjson, textStatus, errorThrown) {
    console.log("parsedJson: " + JSON.stringify(parsedjson));
       
    $('body').append(
        "parsedJson status: " + parsedjson.status + '</br>' + 
        "errorStatus: " + textStatus + '</br>' + 
        "errorThrown: " + errorThrown);        
        
    }
});