0
在uploadify中,我有一個將變量傳入php腳本的問題。代碼如下:jQuery和PHP會話問題
$(document).ready(function() {
var counter = 0;
$("#uploadify").uploadify({
'uploader' : 'scripts/uploadify.swf',
'script' : 'scripts/uploadify.php?upload',
'scriptData' : {'PHPSESSID' : '<? echo session_id(); ?>','counter' : counter},
'cancelImg' : 'cancel.png',
'folder' : 'uploads',
'auto' : true,
'multi' : false,
'buttonText' : 'Browse Image',
onComplete: function(evt, queueID, fileObj, response, data) {
loadPhotos();
counter = $(".upload-photo").size();
alert("Success: "+counter+" Response: "+response);
}
});
});
在onComplete響應中var應返回$ _REQUEST ['counter']的值。它返回0,因爲計數器= 0開始,但它不是在更新:
counter = $(".upload-photo").size();
我也試圖通過這樣的變量:
$("#uploadify").uploadifySettings("scriptData", {'counter' : $(".upload-photo").size()});
但它也不能工作。我究竟做錯了什麼?
loadPhotos函數做什麼?它有異步調用嗎?聽起來像.upload-photo對象在警報運行時仍具有大小0。 – Fosco 2010-10-21 14:24:28
function loadPhotos(){ \t $(「#content_photos」)。load(「scripts/uploadify.php?show」); } – 2010-10-22 00:07:30
loadPhotos函數使用set變量show來執行腳本。這段代碼負責輸出具有class =「upload-photo」的img標籤的HTML – 2010-10-22 00:10:46