0
我正在使用Jquery文件上傳插件。我怎樣才能得到category_id varibale(在processstop回調函數)並將其傳入完成回調函數。從另一個回調函數獲取變量
jupload.fileupload({
url: 'upload.php',
acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i,
maxFileSize: 1536000,
autoUpload: true,
processfail: function(e, data){
alert(data.files[data.index].error);
},
processstop: function (e, data) {
// Create a category
$.post('add_category.php',{'thumbnail':''},function(data) {
var json = data,
obj = JSON && JSON.parse(json) || $.parseJSON(json);
// CATEGORY ID
var category_id = obj.id;
});
},
done: function (e, data) {
// HOW CAN I GET THE `category_id` ABOVE TO USING ADD PRODUCT?
// Add products to category
$.post('product_add.php',{'category_id':category_id},function(data) {
/* ...... */
});
}
});