Search code examples
javascriptjquerysafarijsonp

JSONP error on Safari


The following JSONP JQuery (v1.10.2) call works on all browsers except Safari:-

    $.ajax({
    cache: false,
    type: 'GET',
    url: userExistsUrl,
    dataType: 'json',
    error: function (jqXHR, textStatus, errorThrown) {
        var errText = 'We are not able to process your request at the moment (' + textStatus + ', ' + errorThrown + ')';
        console.error('HTTP response : ' + jqXHR.status);
        console.error(errText);
        displayError(errText);
    },
    success: function (xml) { }
});

On Safari the error function is invoked and the variable textStatus contains the string "error". However if I select the Developer menu option 'Disable cross-origin restrictions' the call works.

As this is just a standard JSONP call, how can I get it to work on Safari without invoking the developer option?


Solution

  • your dataType is wrong

    dataType: 'jsonp'