Javascript jQuery Uploadify中的动态脚本数据
我对javascript和jQuery非常陌生。我正在使用Uploadify将图像上传到服务器。页面上有多个Uploader对象。我需要将正在使用的Uploader对象的id传递给服务器。这就是我到目前为止所做的:Javascript jQuery Uploadify中的动态脚本数据,javascript,jquery,uploadify,Javascript,Jquery,Uploadify,我对javascript和jQuery非常陌生。我正在使用Uploadify将图像上传到服务器。页面上有多个Uploader对象。我需要将正在使用的Uploader对象的id传递给服务器。这就是我到目前为止所做的: $('input.ImageUpload').uploadify({ ... 'scriptData': {'id': ??????}, ... }); 我怎样才能做到这一点?我尝试了“this.id”和“$(this.attr('id')”。我这样做是否正
$('input.ImageUpload').uploadify({
...
'scriptData': {'id': ??????},
...
});
我怎样才能做到这一点?我尝试了“this.id”和“$(this.attr('id')”。我这样做是否正确?我不确定这是否理想,但这就是我最终所做的:
$('input.ImageUpload').each(function() {
$(this).uploadify({
...
scriptData({'id': $(this).attr('id')},
...
});
});
我不确定这是否理想,但这就是我最终所做的:
$('input.ImageUpload').each(function() {
$(this).uploadify({
...
scriptData({'id': $(this).attr('id')},
...
});
});
我就是这样成功地使用它的:
$(document).ready(function() {
$(".upload").each(function() {
$(this).uploadify({
'uploader' : '/code/js/jquery.uploadify/example/scripts/uploadify.swf',
'script' : '/code/js/jquery.uploadify/example/scripts/uploadify.php',
'cancelImg' : '/code/js/jquery.uploadify/example/cancel.png',
'folder' : '<?=$upload_path?>' + $(this).attr('id'),
'queueID' : 'fileQueue',
'auto' : true,
'multi' : false,
'scriptData' : ({'var_name': 'this_var_value'}),
'fileDesc' : 'Images and PDF files only! (JPG, PNG, PDF)',
'fileExt' : '*.pdf;*.jpg;*.jpeg;*.png',
'buttonText' : 'browse' + $(this).attr('id')
});
});
});
<div id="fileQueue"></div>
<input class="upload" type="file" name="ImageUpload" id="_ID_1" /><br />
<input class="upload" type="file" name="ImageUpload" id="_ID_2" /><br />
<input class="upload" type="file" name="ImageUpload" id="_ID_3" /><br />
$(文档).ready(函数(){
$(“.upload”).each(函数(){
$(这个)。上传({
“uploader”:“/code/js/jquery.uploadify/example/scripts/uploadify.swf”,
“script”:“/code/js/jquery.uploadify/example/scripts/uploadify.php”,
“cancelImg”:“/code/js/jquery.uploadify/example/cancel.png”,
'文件夹':''+$(this.attr('id'),
'queueID':'fileQueue',
“自动”:正确,
“多重”:错误,
'scriptData':({'var_name':'this_var_value'}),
“仅限图像和PDF文件!(JPG、PNG、PDF)”,
“fileExt”:“*.pdf;*.jpg;*.jpeg;*.png”,
'buttonText':'browse'+$(this.attr('id'))
});
});
});
我就是这样成功地使用它的:
$(document).ready(function() {
$(".upload").each(function() {
$(this).uploadify({
'uploader' : '/code/js/jquery.uploadify/example/scripts/uploadify.swf',
'script' : '/code/js/jquery.uploadify/example/scripts/uploadify.php',
'cancelImg' : '/code/js/jquery.uploadify/example/cancel.png',
'folder' : '<?=$upload_path?>' + $(this).attr('id'),
'queueID' : 'fileQueue',
'auto' : true,
'multi' : false,
'scriptData' : ({'var_name': 'this_var_value'}),
'fileDesc' : 'Images and PDF files only! (JPG, PNG, PDF)',
'fileExt' : '*.pdf;*.jpg;*.jpeg;*.png',
'buttonText' : 'browse' + $(this).attr('id')
});
});
});
<div id="fileQueue"></div>
<input class="upload" type="file" name="ImageUpload" id="_ID_1" /><br />
<input class="upload" type="file" name="ImageUpload" id="_ID_2" /><br />
<input class="upload" type="file" name="ImageUpload" id="_ID_3" /><br />
$(文档).ready(函数(){
$(“.upload”).each(函数(){
$(这个)。上传({
“uploader”:“/code/js/jquery.uploadify/example/scripts/uploadify.swf”,
“script”:“/code/js/jquery.uploadify/example/scripts/uploadify.php”,
“cancelImg”:“/code/js/jquery.uploadify/example/cancel.png”,
'文件夹':''+$(this.attr('id'),
'queueID':'fileQueue',
“自动”:正确,
“多重”:错误,
'scriptData':({'var_name':'this_var_value'}),
“仅限图像和PDF文件!(JPG、PNG、PDF)”,
“fileExt”:“*.pdf;*.jpg;*.jpeg;*.png”,
'buttonText':'browse'+$(this.attr('id'))
});
});
});