我有这个问题,在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");
?>
任何想法?
答案 0 :(得分:3)
将以下行修改为...
xmlhttp.open(“GET”, “../php/votes.php?random=”+ Math.random(),true);
这将阻止IE通过URI缓存您的请求。