サードパーティのシステムに注文リクエストを送信するために起動する4つのAJAXリクエストを含むページがあります。最初に製品情報が送信され、次に注文に添付する顧客の詳細が送信され、次に注文に該当するメモが送信され、最後に注文を「完了する」ための4番目のリクエストが送信されます。
IE9、Firefox(mac + pc)、Safari(mac + pc)、Chrome(mac + pc)ではすべて正常に動作しますが、IE <9からリクエストが送信されると、AJAXリクエストが正しく実行され、正しい応答が返されます。エラーは発生しませんが、呼び出しごとに異なるセッションを介して送信しているように見えるため、サードパーティシステムは4つの異なる要求を異なるセッションからのものとして認識します。
IE8のアドレスバーを介してリクエストを1つずつ送信すると、すべてが期待どおりに機能し、順序が結び付けられます。セッションが忘れられるのは、jQuery.ajaxを介して送信する場合のみです。
これらのブラウザにセッションを維持させるためにできることはありますか?
これが私のコードです:
//function to add the product to the cart and cascade down to finalise the order
function addToCart(){
var jsonurl = "xxxxx/additem?variationID="+$('input[name="variationID"]').val()+"&token="+APIKey+"&callback=?";
$.ajax({
url:jsonurl,
type:'GET',
dataType:'json',
success:function(data){
if (data.response == "success"){
addLeadCustomer();
} else {
displayEnquiryError();
}
},
error:function(data){
displayEnquiryError();
}
})
}
//function to add the lead customer and cascade down to finalise the order
function addLeadCustomer(){
//add the lead customer to the order in J6
jsonurl = "http://xxxxx/leadcustomer?token="+APIKey+"&details[FirstName]="+$('input[name="Name"]').val()+"&details[Email]="+$('input[name="Email"]').val()+"&details[HomePhone]="+$('input[name="Phone"]').val()+"&callback=?";
$.ajax({
url:jsonurl,
type:'GET',
dataType:'json',
success:function(data){
if (data.response.ID > 0){
updateOrderAdditionalInfo();
}else{
displayEnquiryError();
}
},
error:function(data){
displayEnquiryError();
}
})
}
//function to update the order with the additional info and cascade down to finalise the order
function updateOrderAdditionalInfo(){
//update the order with additional information
jsonurl = "http://xxxxx/updateorder?token="+APIKey+"&details[Notes]="+$('input[name="EnquiryDate"]').val()+"\n\n"+$('select[name="NumberNights"]').val()+" nights\n\n"+$('select[name="NumberPeople"]').val()+" people\n\n"+$('textarea[name="Comments"]').val()+"&callback=?";
$.ajax({
url:jsonurl,
type:'GET',
dataType:'json',
success:function(data){
if (data.response == "success"){
completeOrder();
}else{
displayEnquiryError();
}
},
error:function(data){
displayEnquiryError();
}
});
}
//function to complete the order
function completeOrder(){
//complete the "order"
jsonurl = "http://xxxxx/completeorder?token="+APIKey+"&callback=?";
$.ajax({
url:jsonurl,
type:'GET',
dataType:'json',
success:function(data){
if (data.response == "success"){
$('.waiting').fadeOut(function(){
$('.enquirySuccess').fadeIn();
$('.cartItemsHolder').empty();
$('.cartItemsHolder').html('We have received your itinerary');
})
}
},
error:function(data){
displayEnquiryError();
}
});
}
$('#Form_enquiryForm').submit(function(){
validateForm();
if (failedValidation == 0){
$(this).fadeOut(function(){
$('.waiting').fadeIn();
//add the package to the cart
addToCart();
});
}
return false;
});
更新:IE8のキャッシュが原因である可能性があるという印象につながる投稿に出くわしました。これにより、AJAX呼び出しでcache:falseを試し、クエリ文字列に乱数パラメーターを追加しました(&cachebuster = "+ Math.random())が、どちらも問題を解決しませんでした。