我对Ajax很陌生,但我正在尝试创建Ajax&>PHP连接,代码如下。
file1.php
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
</head>
<input type="text" id='demo'>
<input type="button" onclick='ajaxCall()' value='23' >
<script>
function ajaxCall()
{
document.getElementById('demo').value="343434";
xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange=function(){
if(xmlhttp.requeststate==4 && xmlhttp.status==200){
document.getElementById('demo').value="4444343434";
document.getElementById('demo').value=xmlhttp.responseText;
}
}
xmlhttp.open("GET","test.php",true);
xmlhttp.send();
}
</script>
</body>
</html>
和相应的test.php:
<?php
echo "me";
?>
现在,当我单击该按钮时,TextBox的值将更改为343434,但在ajax调用中不会更改,即使它不会更改为4444343434。我目前正在ubuntu14.04LTS上运行php5.5.6。