jQuery发送多个formdata

时间:2013-09-19 10:29:49

标签: javascript php jquery html blueimp

目前我的代码是

$('#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;
     }
});

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

谢谢!

1 个答案:

答案 0 :(得分:3)

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

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

将两个值都放入一个对象中:

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