Workaround bug 5383, complete called twice in Ajax with JSONP

Workaround bug 5383, complete called twice in Ajax with JSONP

When JSONP is called to a service on the same host Complete is called twice.(We also experienced the success
callback being called twice). Someone posted a bug about it http://dev.jquery.com/ticket/5383 .
 
Does anybody else has this problem?
If so, what is your solution?

I use a local  boolean variable to check whether the Complete was already called. However this does not feel good. Example:

  1. function

    myFunc(fComplete, arg1) {

    var completeNotCalled=true;

    function fGuardedComplete(data, textMessage) {

    if(completeNotCalled){

    completeNotCalled=

    false;

    f(data);

    }

    }

    var url = BASEURL+ "?get=m&n=m&f=";

    url = url + arg1;

    var options = {

    'url': url,

    async:

    false,

    complete: fGuardedComplete,

    dataType:

    "jsonp",

    "jsonp": "p"

    };

    $.ajax(options);

    }

 

    • Topic Participants

    • kruse