我的代碼如下JavaScript的AJAX不工作
<script type="text/javascript">
function saveack()
{
var raf=document.getElementById('find_raf').value;
var phone=document.getElementById('update_phone').value;
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
document.getElementById("res").innerHTML="<img src='../images/ajax-loader-2.gif' />";
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
alert("asd");
document.getElementById("res").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("get","updateCustomerDetail.php?raf="+raf+"&phone="+phone,true);
xmlhttp.send();
}
和短我的html代碼是
<form method="post" >
<tr>
<td align="right" width="50%" bgcolor="#9FCAE9" style="font-weight:800; font-size:14px; color:#006;">RAF No.</td>
<td width="50%" align="left" bgcolor="#E8F8FF" style="color:#006"><input type="text" style="border:none" name="find_raf" id="find_raf" onBlur="fetchDetails();" /><span id="result_raf"></span></td>
</tr>
<tr>
<td align="right" bgcolor="#9FCAE9" style="font-weight:800; font-size:14px; color:#006;">Customer Phone</td>
<td align="left" bgcolor="#E8F8FF" style="color:#006"><input type="text" style="border:none" size="30" name="update_phone" id="update_phone" /></td>
</tr>
<tr align="center">
<td colspan="2"bgcolor="#E8F8FF" style="color:#006"> <input type="submit" name="update_raf" id="update_raf" value="update" onClick="saveack();" /><?=$success ?></td>
</tr>
<tr align="center">
<td><div id="res"></div></td>
</tr>
</form>
當我回聲$ _GET ['英國皇家空軍在updateCustomerDetail.php什麼都不顯示..can誰能幫助 確切位置,我已經wrong..for測試目的,我只是裏面 給了警告,如果(xmlhttp.readyState == 4 & & xmlhttp.status == 200) ,但警報不來
試試這個https://github.com/global-source/javascript_ajax –