This the part of my code where I create the request. ( I do not want to use jquery)
var xr = new XMLHttpRequest();
console.log(xr);
xr.onreadystatechange = function () {
console.log(xr.readyState,xr.status);
if(xr.readyState == 4 && xr.status == 200) {
var data=xr.responseText;
alert(data.innerHTML);
console.log(data);
}
var params ="param1="+movieName+"¶m2"+movieGenre ;
xr.open("GET","./saveMovie.php"+"?"+params,true);
xr.send();
}
You need to open and sed the XHR outside the callback function.
var xr = new XMLHttpRequest();
console.log(xr);
xr.onreadystatechange = function () {
console.log(xr.readyState,xr.status);
if(xr.readyState == 4 && xr.status == 200) {
var data=xr.responseText;
alert(data.innerHTML);
console.log(data);
}
}
var params ="param1="+movieName+"¶m2"+movieGenre ;
xr.open("GET","./saveMovie.php"+"?"+params,true);
xr.send();
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.