0
我使用Malsup的jQuery Form Plugin異步上傳文件,as per this question。如何在使用jQuery Form Plugin上傳文件時提交其他數據?
它的偉大工程的上傳文件,但我感興趣的文件一起發送的附加數據(比如上傳它的人的用戶名。
是否有某種方式來添加這個額外的數據?
下面是當前的代碼,上傳文件的工作原理:
(假設與id=upload
HTML表單標準<input type=file/>
)
// site/js/app.js
var app = app || {};
(function($){
})(jQuery);
// prepare the form when the DOM is ready
$(document).ready(function() {
var options =
{
url: 'http://localhost:3000/file_upload',
dataType: 'json',
success: function(response, statusText, xhr, form)
{
alert('success!');
};
$("#upload").ajaxForm(options);
});