I have this issue, in FF it works great but in IE only works once... the html is
<form>
<input type="button" value="test" onclick="javascript:vote();"/>
</form>
the 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
$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);
This will prevent IE from caching your request by URI.
精彩评论