[英]How can I run a httprequest inside function first thing before page loads?
Ive tried on load atribute in body tag without success我试过在body标签中加载属性但没有成功
<body onload=\"updateGroup()\">
nor function calling inside echo: echo "<script> updateGroup(); </script>";
也不是 function 在 echo:
echo "<script> updateGroup(); </script>";
I'm open to critics!我对批评持开放态度!
function updateGroup(){
var http = new XMLHttpRequest();
var url = \"../requests/updateGroup.php\";
http.open(\"POST\", url, true);
//Send the proper header information along with the request
http.setRequestHeader(\"Content-type\", \"application/x-www-form-urlencoded\");
http.onreadystatechange = function() {//Call a function when the state changes.
if(http.readyState == 4 && http.status == 200) {
}
}
http.send();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.