我正在使用教程中使用的优秀Jquery-Filedrop [weixiyen],我遇到了一个试图发送动态POST变量的问题,解释如下:
我有一个html表单选择下拉列表(photo_tab_index),用户可以选择幻灯片编号(例如1-5),然后选择一个用户将照片放到上传到Web服务器的Dropbox画布.
在filedrop javascript中我有以下内容:
$(function(){
var dropbox = $('#dropbox'),
message = $('.message', dropbox);
var slideshow = document.getElementById('photo_tab_index').value;
dropbox.filedrop({
// The name of the $_FILES entry:
paramname:'pic',
data: {
param1: slideshow, // send POST variables
},
...
// Called before each upload is started
beforeEach: function(file){
if(!file.type.match(/^image\//)){
alert('Only images are allowed!');
return false;
}
},
...
Run Code Online (Sandbox Code Playgroud)
我遇到的问题是,javascript在呈现页面时会读取photo_tab_index的值(因此总是以"1"的形式发送),但我真正想要的是它在照片显示时读取幻灯片下拉值落在投递箱上.在我有限的JQuery知识中,我有一种感觉,我想要更新beforeEach:函数中的dropbox.filedata"data:param1"字段,但我不确定如何引用它?