jQuery的文件上传模块发送额外的参数 [英] jquery file upload module sending extra parameter

查看:356
本文介绍了jQuery的文件上传模块发送额外的参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用jQuery文件上传插件。我增加了一个额外的按钮来告诉服务器来完成的一切,这是假设发送如下额外的参数:

I'm using jquery file upload plugin. I added an extra button to tell the server to finalize everything, this is suppose to send an extra parameter as below:

$('.btn-finalize').click(function(){
    $('#fileupload').fileupload({
        dataType:'json',
        formData:{name:'finalize',value:'1'},
        url: 'server/php/'
       });
});

该单击处理程序被调用,但没有要求越来越发送。为什么呢?

This click handler is called, but no request is getting sent. why?

推荐答案

<一个href="https://github.com/blueimp/jQuery-File-Upload/wiki/Basic-plugin#wiki-how-to-start-uploads-with-a-button-click"相对=nofollow>逆文档咨询点击 autoupload 处理程序。

$('#fileupload').fileupload({
    autoUpload: false,
    formData: {
        name: 'finalize',
        value: '1'
    },
    add: function (e, data) {
        $('.btn-finalize').click(function () {
            data.submit();
        })
    },
    done: function (e, data) {    
        console.log(data.formData.name); // Show "finalize" in the console
    }
});

测试小提琴

这篇关于jQuery的文件上传模块发送额外的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆