私は、他の多くの人が IE とおそらくキャッシングを使用するのと同じように問題を抱えています。私はオークション サイトを持っており、ユーザーが入札をクリックすると、次のコードが起動します。
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 (update-auction.php) では、この投稿された ajax データを取得し、データベースを更新します。
$auction_id=$_POST['auct_id'];
$user_id=$_POST['user_id'];
$usr=$_POST['username'];
$enddate=$_POST['end_date'];
//Database update
このコードは、Firefox または Chrome でうまく機能します。
したがって、問題は、最初に入札をクリックすると機能しますが、2番目のページに移動すると(以下のコード):
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+"|");
}
});
}
(ajax呼び出しを起動して2番目のページを表示するonClick)、これは機能しなくなりfunction bid(id)
ます。cache:false,
投稿への追加new Date().time();
やJSONでのデータの投稿などのソリューションを検索しましたが、うまくいきませんでした。(また、データを JSON 形式で投稿しようとしたときに、いくつかの構文エラーが発生しました: Unexpected token < および parse error など)。私はこの作業コードで最も簡単な解決策を見つけようとしています...何かアイデアはありますか?