我有像许多其他人一样的问题,IE和可能的缓存。我有一个拍卖网站,当用户点击竞价,火灾这段代码:在Internet Explorer中第二次调用后jQuery ajax不工作
function bid(id){
var end_dateUP=0;
var tupdate=jq("#tupdate"+id).val();
if (tupdate=="lvl1"){
end_dateUP=20;
}else if (tupdate=="lvl2"){
end_dateUP=15;
}else if (tupdate=="lvl3"){
end_dateUP=10;
}else{
end_dateUP=0;
}
var url = "http://localhost/bid/comet/update-auction.php"; // the script where you handle the form input.
var user_id=<?php echo json_encode($user_id);?>; //here i'm getting id from SESSION
var user_name=<?php echo json_encode($user_name); ?>; //here i'm getting user name from SESSION
jq.ajax({
type: "POST",
async: false,
url: url,
data: {"auct_id" : id, "user_id" : user_id, "username" : user_name, "end_date" : end_dateUP}, // serializes the form's elements.
cache:false,
success: function(data)
{
setTimeout('waitForMsg()',100);
jq("#tupdate"+id).val("");
jq('#bid-container'+id).animate({ backgroundColor: "#659ae0" }, 50);
jq('#bid-container'+id).animate({ backgroundColor: "#FFF" }, 500);
},
error: function(xhr, errorString, exception) {
alert("xhr.status="+xhr.status+" error="+errorString+" exception=|"+exception+"|");
}
});
}
和PHP(更新auction.php)我得到这个贴阿贾克斯数据和更新我的数据库:
$auction_id=$_POST['auct_id'];
$user_id=$_POST['user_id'];
$usr=$_POST['username'];
$enddate=$_POST['end_date'];
//Database update
此代码在Firefox或Chrome中非常适用。
所以问题是,当我点击出价第一次,它的工作原理,但是当我去到第二页(下面的代码):
function pageClick(page){
var url = "http://localhost/bid/auctions-ajax"; // the script where you handle the form input.
jq.ajaxSetup({ cache: false }); //this line before $.ajax!!!
jq.ajax({
type: "POST",
url: url,
data: {"page" : page},
async:false, //to sem dodal za časovni zamik
cache: false,
success: function(data)
{
jq("#a_loader").hide();
jq("#show-category").html(data); // show response from the php script.
},
error: function(xhr, errorString, exception) {
alert("xhr.status="+xhr.status+" error="+errorString+" exception=|"+exception+"|");
}
});
}
(的onClick它将触发Ajax调用并显示第二页)那么function bid(id)
停止工作。我搜索了像cache:false,
这样的解决方案,并添加了new Date().time();
来发布和发布JSON数据,但没有运气。 (另外当我试图以JSON格式发布数据时,我遇到了一些语法错误:意外的令牌<和解析错误等等)。我只是试图找出这个工作代码的最简单的解决方案...任何想法?
你是如何 “去第二页”?你是否在修改DOM,并替换具有点击处理程序的元素?然后,您需要重新绑定处理程序,或者使用'.on()'使用委托。 – Barmar 2013-04-11 00:26:36
我已更新帖子并添加了代码,我如何转到第二页... – 2013-04-11 00:31:19
是否在'#show-category'内出价? – Barmar 2013-04-11 00:40:42