我正在嘗試使用Uploadify進行Ajax文件請求。但是,我遇到了一個非常奇怪的情況。這裏是我的代碼:Uploadify預防未來的Ajax請求
$.ajax({
type: "POST",
data: "choice="+choice,
url: "getformdata.php",
cache: false,
async: false,
success: function(msg) {
$(".file-upload").each(function() {
var $p = $(this).parent();
$(this).uploadify({
'swf': 'uploadify.swf',
'uploader': 'uploadify.php',
'fileTypeDesc': '.doc, .docx, or .pdf',
'fileTypeExts' : '*.doc; *.docx; *.pdf',
'onUploadError' : function(file, errorCode, errorMsg, errorString) {
alert('The file ' + file.name + ' could not be uploaded: ' + errorString);
},
'onUploadSuccess' : function(file, data, response) {
$($p).find("input[type='hidden']").val(data);
$($p).find(".file-name span").text(data);
}
});
});
}
});
因爲它是目前,如果我試圖讓另一個Ajax請求,PHP不知何故不知道我的任何會話變量。只要我取出.uploadify()方法,它就會再次知道我的會話變量。
這到底是什麼原因造成的?有沒有辦法解決它?
我在兩者中都調用了session_id(),它看起來是一樣的,不過我會嘗試添加session_start()來uploadify。 – 2012-08-16 22:39:24
我試着給除了Uploadify以外的所有頁面添加一個特定的會話ID,但這沒有幫助。我真的不明白,因爲Uploadify確實嘗試通過PHP創建會話。 – 2012-08-16 23:57:58