Php AJAX请求在IE中只工作一次

Php AJAX请求在IE中只工作一次,php,ajax,internet-explorer,xmlhttprequest,Php,Ajax,Internet Explorer,Xmlhttprequest,我有这个问题,在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 I

我有这个问题,在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>

功能投票(){
if(window.XMLHttpRequest)
{//IE7+、Firefox、Chrome、Opera、Safari的代码
xmlhttp=新的XMLHttpRequest();
}
其他的
{//IE6、IE5的代码
xmlhttp=新的ActiveXObject(“Microsoft.xmlhttp”);
}
open(“GET”,“./php/vows.php”,true);
xmlhttp.send(空);
}
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");


?>


有什么想法吗?

将以下行修改为

open(“GET”, “./php/vots.php?随机=”+ Math.random(),true)


这将阻止IE通过URI缓存您的请求。

第二次会发生什么?嗨!欢迎加入!您可以通过在每行的开头放置4个空格来格式化代码(编辑器顶部的
{}
按钮就是这样做的);有关更多信息,请参阅;;这次我是为你做的:-);;我试图重新添加
缓存。第二次请求不起作用,因为浏览器避免两次加载相同的内容。常见的解决方法是在url中附加一个随机id。。。或者使用,保证可以跨浏览器工作,并且有一个“无缓存”选项。@65F可能,但是jQuery有一个显式参数来关闭缓存。我认为它在内部所做的也只是在一些浏览器中添加一个随机ID,但它是以静默的方式这样做的。不管怎样,你的答案是+1