[英]AJAX request only works once in IE
我有這個問題,在FF中效果很好,但在IE中僅工作一次... html是
<form>
<input type="button" value="test" onclick="javascript:vote();"/>
</form>
javascript
<script type="text/javascript">
function vote(){
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET","../php/votes.php",true);
xmlhttp.send(null);
}
</script>
而PHP代碼只是一個更新
<?php
$con = mysql_connect("localhost","mylog","mypass");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db('versus',$con);
mysql_query("update picture_vs set votes = votes + 1");
?>
任何想法?
將以下行修改為...
xmlhttp.open(“ GET”,“ ../php/votes.php?random=” + Math.random(),true);
這將防止IE通過URI緩存您的請求。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.