The official documentation of jQuery ( async ajax section ) says that:
Cross-domain requests and dataType: "jsonp" requests do not support synchronous operation.
However this works in all recent browsers but firefox version >= 20. Here is the type of calls i'm making:
$.ajax({
type : "GET",
async: false,
dataType : "text",
url : link,
xhrFields: { withCredentials: true },
success: function(response){
console.log("success ");
},
error: function(error){
console.error(error);
}
});
Does anyone have a clue why this is happening ?
UPDATE: Ive tested both with jQuery and vanilla XHR the error is always the same
[Exception... "A parameter or an operation is not supported by the underlying object" code: "15" nsresult: "0x8053000f (InvalidAccessError)"
The official documentation of jQuery ( async ajax section ) says that:
Cross-domain requests and dataType: "jsonp" requests do not support synchronous operation.
However this works in all recent browsers but firefox version >= 20. Here is the type of calls i'm making:
$.ajax({
type : "GET",
async: false,
dataType : "text",
url : link,
xhrFields: { withCredentials: true },
success: function(response){
console.log("success ");
},
error: function(error){
console.error(error);
}
});
Does anyone have a clue why this is happening ?
UPDATE: Ive tested both with jQuery and vanilla XHR the error is always the same
Share Improve this question edited May 21, 2013 at 14:03 mfreitas asked May 21, 2013 at 10:59 mfreitasmfreitas 2,4053 gold badges32 silver badges42 bronze badges 6[Exception... "A parameter or an operation is not supported by the underlying object" code: "15" nsresult: "0x8053000f (InvalidAccessError)"
- 1 You're not using dataType: "jsonp", so it must be the cross domain part, but you haven't showed us from where/to where this request is being made. – tandrewnichols Commented May 21, 2013 at 11:06
- What does happen in FF? What does the network inspector tell you? – Bergi Commented May 21, 2013 at 11:12
- @tandrewnichols Im using CORS in order to make cross-domain requests. – mfreitas Commented May 21, 2013 at 11:34
- @Bergi in the network inspector tab its not showing any request. – mfreitas Commented May 21, 2013 at 11:34
- I need to have synchronous requests while using CORS, if i remove async:false the request is made with success. – mfreitas Commented May 21, 2013 at 11:43
1 Answer
Reset to default 18Use beforeSend
instead of xhrField
.
$.ajax({
type : "GET",
async: false,
dataType : "text",
url : link,
beforeSend: function(xhr) {
xhr.withCredentials = true;
},
success: function(response){
console.log("success ");
},
error: function(error){
console.error(error);
}
});