开发者

AJAX request only works once in IE

开发者 https://www.devze.com 2023-02-22 06:57 出处:网络
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();\"/>

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消