I’m not sure why my code won’t run.
Here is my JavaScript code:
fuction update(id, value){
xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange=function(){
if(xmlhttp.readyState==4 && xmlhttp.status == 200){
document.getElementById("response").innerHTML=xmlhttp.responseText;
}else{
document.getElementById("response").innerHTML=
"AJAX Failed: " + xmlhttp.status;
}
}
xmlhttp.open("GET","updatevis.php?id="+id+"&value="+value);
document.getElementById("response").innerHTML="Sending Ajax Request";
xmlhttp.send();
}
This is my HTML form code:
<input type="checkbox" name="visible" id="'.$id.'" checked="'.$checked.'" onchange="update('.$id.', '.$visible.')" />
The id would be anything from 1-whatever its auto increment, visible is a int, either 1 or 0 Checked is just my code to have it start checked or not
I have already run this code through chrome and Firefox, chrome gave my two errors a Unexpected identifier on line 5 (the line where I define the function) and a ReferenceError saying the function is not defined, on line 30 (the checkbox one)
You’ve miss-spelt
functionon the first line asfuction. Change this and everything should work as expected.