I am using HTML5, jQuery 1.6.1, jQuery Mobile 1.0.1.
I am using below code to make an Ajax request. It's working fine in Chrome but I got the below error while testing in Firefox 14.0.1.
Use of XMLHttpRequest's withCredentials attribute is no longer supported in the synchronous mode in window context.
Code:
$.ajax({
type: "GET",
dataType: "json",
async: false,
beforeSend: function (xhr){
xhr.setRequestHeader('Authorization', make_base_auth(UserId, Password));
},
xhrFields: {
withCredentials: true
},
success:function(data){
console.log("Success");
},
error:function(xhr,err){
console.log("Failed" );
}
});
Please help me out on this.
The solution is simple : don't use async: false
in $.ajax
.
It's deprecated in newer version and you don't need it. It was always a bad idea to use it. Execute what you need to do with result from the success callback (just like your console.log
).
From the documentation (1.8) :
Note that synchronous requests may temporarily lock the browser, disabling any actions while the request is active. As of jQuery 1.8, the use of async: false with jqXHR ($.Deferred) is deprecated; you must use the complete/success/error callbacks.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With