【发布时间】:2018-07-27 09:45:43
【问题描述】:
// Show Cart Quantity
function showCartById(){
var inProcess = false;//Just to make sure that the last ajax call is not in process
if (inProcess) {
return false;//Another request is active, decline timer call ...
}
inProcess = true;//make it burn ;)
var sId = $(this).attr('sid');
var data = 'sId='+sId;
jQuery.ajax({
url: 'cart.php', //Define your script url here ...
data: data, //Pass some data if you need to
method: 'POST', //Makes sense only if you passing data
success: function(answer) {
alert(answer)
inProcess = false;//Queue is free, guys ;)
},
error: function() {
//unknown error occorupted
inProcess = false;//Queue is free, guys ;)
}
});
}
我想通过 ajax 请求方法传递我的 PHP Session_id()。但如果没有 Session_id() 它工作得很好。
【问题讨论】:
-
您使用的是负载平衡服务器吗?如果没有,那么服务器已经知道你的 session id,你不需要传递它
-
尝试在数据中使用 JSON 格式而不是 sId=sId,例如..... { "sId" : sessionId}
-
如果您想在 cart.php 中发送会话值,只需在 cart.php 顶部使用 session_start(),您设置的所有会话都将可用。