jsonp is not firing beforeSend?

Posted by user283357 on Stack Overflow See other posts from Stack Overflow or by user283357
Published on 2010-05-05T15:44:45Z Indexed on 2010/05/05 15:48 UTC
Read the original article Hit count: 519

Filed under:
|
|

Hi All,

I am working on a project to call a webservice from different domain using $.ajax with dataType set to jsonp.

    $.ajax({
        type: "GET",
        url: testService.asmx,
        async: true,
        contentType: "application/json; charset=utf-8",
        dataType: "jsonp",

        beforeSend: function (XMLHttpRequest) {
            alert('Before Send'); //Nothing happnes
        },
        success: function (response) {
            alert('Success'); //this was fired
        },
        complete: function (XMLHttpRequest, textStatus) {
            alert('After Send'); //this was fired
        }
    });

The problem is I have a ...loading animation which I want to display while the web service request is being processed. I tried using "beforeSend:" to show the loading animation but it seems like "beforeSend" is not getting fired.

The animation works fine when the app is on the same domain (using jsonp) but when I move the app into a different server, everything works except "beforeSend" is not getting called. So users will not be able to see the loading animation.

Is there any workaround for this?

© Stack Overflow or respective owner

Related posts about jsonp

Related posts about beforesend