2

目前我的代码是

$('#fileupload').bind('fileuploadsubmit', function (e, data) {
    // The example input, doesn't have to be part of the upload form:
    var adultinput = $('#adult');
    data.formData = {adult: adultinput.val()};
    if (!data.formData.adult) {
       input.focus();
       return false;
     }
});

从html代码发送具有成人价值的帖子数据效果很好

但是,我也想发送另一个名为 thumbsize 的输入表单,

我试过了

$('#fileupload').bind('fileuploadsubmit', function (e, data) {
     // The example input, doesn't have to be part of the upload form:
    var adultinput = $('#adult');
    var thumbsize = $('#thumbsize');
    data.formData = {adult: adultinput.val()};
    data.formData = {thumbsize: thumbsize.val()};
    if (!data.formData.adult) {
        input.focus();
        return false;
     }
});

但这似乎不起作用,无论如何我可以发送另一个参数吗?

谢谢!

4

1 回答 1

3
data.formData = {adult: adultinput.val()};
data.formData = {thumbsize: thumbsize.val()};

在第二行中,您将覆盖您在第一行中分配的内容。

将两个值放入一个对象:

data.formData = {adult: adultinput.val(), thumbsize: thumbsize.val()};
于 2013-09-19T10:32:41.193 回答