[英]AJAX request only works once in IE
I have this issue, in FF it works great but in IE only works once... the html is 我有这个问题,在FF中效果很好,但在IE中仅工作一次... html是
<form>
<input type="button" value="test" onclick="javascript:vote();"/>
</form>
the javascript 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>
and the PHP code is only a update 而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");
?>
any idea? 任何想法?
Modify the following line to... 将以下行修改为...
xmlhttp.open( "GET", "../php/votes.php?random=" + Math.random(), true); xmlhttp.open(“ GET”,“ ../php/votes.php?random=” + Math.random(),true);
This will prevent IE from caching your request by URI. 这将防止IE通过URI缓存您的请求。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.