我测试的发送和接收数据使用jQuery PHP文件和我有IE的问题(即时通讯使用IE9,但我和IE8和IE7选中)的jQuery - 获得()问题与IE7,8,9
当我点击我的div时,我向服务器发送一个“ID”,PHP文件返回答案,其工作和jQuery在其他Div和alert msg中显示结果。
当我更改接收到的php文件中的代码时,如果再次点击我的div中的一个,那么显示相同msg的jQuery即使我更改了代码,现在重播msg也不同。
当我关闭并重新打开IE时解决了这个问题。
这个问题不会发生与Firefox和铬,没有任何人有任何想法?
HTML文件:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>test</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=9" />
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
$('.user').click(function(){
var id_value = $(this).data('friendid');
$.get('test1.php', {id: id_value}, function(data) {
$('#show').html(data);
alert(data);
});
})
})
</script>
</head>
<body>
<div class="user" data-friendid="1">
<img src='webimgs/nopf.jpg' alt="test" />
<h4> fullname</h4>
<br />
</div>
<div class="user" data-friendid="2">
<img src='webimgs/nopf.jpg' alt="test2"/>
<h4> fullname</h4>
<br />
</div>
<div id="show" style="color:red">
</div>
</body>
</html>
和PHP文件:
<?php
if ($_GET["id"]==1) { echo "you choose number is " . $_GET["id"].", thanks." ; }
?>
如果您已经在使用jQuery,为什么不用'$(this).data('friendid')'来代替? – Bojangles
你是对的,我改变了,但这不是解决问题的任何想法? – user3780061
这听起来像是一个AJAX缓存问题。尝试使用'$ .ajaxSetup({cache:false})'在进行'$ .get()'调用之前破解缓存。 – Boaz