AJAX请求只能在IE中运行一次 [英] AJAX request only works once in IE

查看:161
本文介绍了AJAX请求只能在IE中运行一次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个问题,在FF它的伟大工程,但在IE浏览器只能一次... 在HTML是

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>

的JavaScript

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>

和PHP的code是只有更新

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");


?>

任何想法?

推荐答案

修改以下行...

xmlhttp.open(GET,   ../php/votes.php?random=+   的Math.random(),TRUE);

xmlhttp.open( "GET", "../php/votes.php?random=" + Math.random(), true);

这将$ P $由URI缓存你的要求pvent IE浏览器。

This will prevent IE from caching your request by URI.

这篇关于AJAX请求只能在IE中运行一次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆