简体   繁体   中英

synchronous ajax call using jQuery not working on firefox

I am trying to make an ajax call setting async property to false but it gets error while it works on chrome and ie.

I know Firefox highly recomends async ajax call due to user experience issues, but i need to get response before continue doing other things and its ok (and mandatory) to wait until the response is received..

Here is the working and not working code, any help would be appreciated.

    data = $.ajax({
        url: Common.serverPath + 'recovery/list',
        crossDomain: true,
        dataType: 'json',
        async: true,
        type: 'GET',
        contentType: 'application/json',
        xhrFields: {
            withCredentials: true
        }
    });
    setTimeout(function(){ console.log(data.statusText);
    },3000);

console:OK

    data = $.ajax({
        url: Common.serverPath + 'recovery/list',
        crossDomain: true,
        dataType: 'json',
        async: false,
        type: 'GET',
        contentType: 'application/json',
        xhrFields: {
            withCredentials: true
        }
    });
    setTimeout(function(){ console.log(data.statusText); },
    3000);

console:InvalidAccessError: A parameter or an operation is not supported by the underlying object

chrome and ie work fine in both

I found out that "Cross-domain requests and dataType: "jsonp" requests do not support synchronous operation." even if it does in ie and chrome :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM