I am having trouble understanding the ‘async’ part of XMLHttpRequest().
I have written a website www.weemfg.com using javascript and PHP using
syncronous http which works fine using firefox however when i use chrome
i get warnings about my use of ‘synchronous’ being deprecated. I want
the data returned to my call of majax below. using async it will go
to someplace else and how will i know when it is there. allowing timeout
to synchronous xhttp might solve my problem.
what i want … let rsp = majax(“qry,”select * from sometable”).
function majax(op, argv) {
/* ------------------------------------------------------------------
this is synchronous. Since the user has initiated communication
and this is a single purpose app there is no need for 'async'
there will always be a rsp[0]
------------------------------------------------------------------- */
//console.log("at majax op="+op+" argv="+argv);
let pdata = new FormData();
pdata.append('op', op);
pdata.append('argv', argv);
let rsp = false;
let xhr = new XMLHttpRequest();
xhr.open('POST', 'mfg.php', false); // false=synchronous
xhr.onload = function () {
rsp = this.responseText;
}
xhr.send(pdata); // this wont return until onload finishes
return rsp;
}
i have tried to accomplish what i want using async without success.