Answer the question
In order to leave comments, you need to log in
"Synchronous XMLHttpRequest on main thread is deprecated" error in some browsers. How to fix?
In google chrome the code runs fine. But in firefox and opera, this code does not work - it gives an error.
function GetAddFormAndOpenModal(form, promo, code){
if(form){
$.post('/personal/items/add/',
{ itemadd : form['itemadd'].value, submitform : form['submitform'].value, checkbutton : form['checkbutton'].value,
promo : form['promo'].value, code : form['code'].value, lastchoose : form['lastchoose'].value },
function(html){
$("#chooseAdd div.content").html(html);
}, "html");
}else{
$.post("/personal/items/add/?promo="+promo+"&code="+code, function(html){
OpenModalWindow2('chooseAdd');
$("#chooseAdd div.content").html(html);
}, "html");
}
}
Answer the question
In order to leave comments, you need to log in
This is the jamb of the browser developers.
request.open('POST', "/personal/items/add/", true);
Since "true" is an asynchronous connection, not a synchronous one, it turns out that the browser is swearing by mistake. Personally, this happens to me when the connection to the server where request.open is being hammered is simply not available, and if the server is available, then these errors do not exist.
I rewrote the code to:
function GetAddFormAndOpenModal(form, promo, code){
if(form){
var params = 'itemadd=' + encodeURIComponent(form['itemadd'].value)
+ '&submitform=' + encodeURIComponent(form['submitform'].value)
+ '&checkbutton=' + encodeURIComponent(form['checkbutton'].value)
+ '&promo=' + encodeURIComponent(form['promo'].value)
+ '&code=' + encodeURIComponent(form['code'].value)
+ '&lastchoose=' + encodeURIComponent(form['lastchoose'].value)
;
var request = new XMLHttpRequest();
request.onreadystatechange = processRequestChange;
request.open('POST', "/personal/items/add/", true);
request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
request.send(params);
}else{
var request = new XMLHttpRequest();
request.onreadystatechange = processRequestChange;
request.open('GET', "/personal/items/add/?promo="+promo+"&code="+code, true);
request.send(null);
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question