0
我試圖在成功調用Realex(處理信用卡事務的公司)後清除一些會話變量。會話變量包含我的購物車內容,所以一旦交易成功,我想清除它。我的代碼如下:Ajax調用不按預期方式工作
jQuery.ajax({
async: false,
url: templateuri+'/realex_go_pay.php',
type: 'post',
data: {
amount: ordertotal,
orderid: orderid,
orderkey: orderkey,
cardtype: type,
cardnumber: number,
cardname: name,
expdate: expiry,
cvv: cvv,
issueno: issueno
},
success: function(data){
// Hide payment indicator.
jQuery('.realex_payindicator').hide();
data = data.split("|");
if (data[0] == '00'){
// Empty the shopping cart.
jQuery.ajax({
async: false,
url: templateuri+'/realex_empty_cart.php'
});
self.location = thankyoupage+'?order='+orderid+'&key='+orderkey;
}else{
alert(data);
}
}
});
第一次調用realex_go_pay.php工作沒有問題。但第二次調用realex_empty_cart.php似乎沒有工作。在realex_empty_cart.php,我只有兩行代碼:
unset($_SESSION['cart']);
unset($_SESSION['coupons']);
你有螢火蟲或類似的東西檢查?是否已經發出了Ajax請求? realex_empty_cart.php是否成功響應? – arunes 2012-03-08 20:45:01
確保你在php文件中回覆「成功」消息 – adamdehaven 2012-03-08 20:46:53
使第二個Ajax調用也是一個帖子並添加'data:{}' – Archer 2012-03-08 20:47:48