Issues with Ajax
var xmlHttp;
function S_xmlhttprequest () {
if (window. ActiveXObject) {
Xmlhttp=new ActiveXObject ("Microsoft.XMLHTTP");
}
else if (window. XMLHttpRequest) {
Xmlhttp=new XMLHttpRequest ();
}
}
function Myajax (URL) {
S_xmlhttprequest ();
Xmlhttp.open ("GET", "for.php?id=" +url,true);
Xmlhttp.onreadystatechange=byphp ();
Xmlhttp.send (NULL);
}
function byphp () {
var Byphp1=xmlhttp.responsetext;
document.getElementById ("PHP"). innerhtml= "Test";
}
The previous two functions are all right. There is a problem with the last function. I put Var byphp1=xmlhttp.responsetext this sentence after the last foreground can display test, but with the Var byphp1=xmlhttp.responsetext, the page is displayed error.
The content of for.php is
if ($id =$_get[' id ') {
for ($i =1; $i <10; $i + +) {
echo $id;
}
Exit ();
}
?>
------Solution--------------------
Did you write the wrong code? Remember knot stickers! Sent more than 10 minutes to find the error! Write you a complete, your for.php page does not change
PHP code
test with a click Trigger!--suspect you're calling it wrong, you're not going to call byphp.-->
----- -Solution--------------------
Install Firefox +firebug, can debug JS where there are errors.