简体   繁体   English

使用JQuery表单插件触发文件上传中的提交

[英]Triggering Submit in File Upload with JQuery Form Plugin

I'm using the JQuery Form Plugin for a file upload. 我正在使用JQuery表单插件进行文件上传。

now, at the moment i'm using a regular submit button, but i'd much rather like to have a div trigger the submit. 现在,此刻我正在使用常规的提交按钮,但我更希望有一个div触发提交。

I tried this... 我试过了

$(document).on('click', '#settings_changeprofilepic_dialog1_submit', function(event){
        $(document).find('#UploadNewImage').submit();
});

('#settings_changeprofilepic_dialog1_submit' is my new submit div) (“#settings_changeprofilepic_dialog1_submit”是我的新提交div)

('#UploadNewImage' is my form) (“ #UploadNewImage”是我的表单)

But it just won't fire... 但是它不会开火...

Can someone help me with this? 有人可以帮我弄这个吗? I've tried to google this problem, but the terms JQuery, Form, Submit, File Upload, and so on seem too ambiguous to get the answer I'm looking for... 我试图用谷歌搜索这个问题,但是术语JQuery,Form,Submit,File Upload等似乎太含糊,无法获得我要的答案...

From what you have provided it is a bit difficult to determine the cause of the problem. 根据您提供的信息,很难确定问题的原因。 Lets try some simple debugging to get an idea of what might be happening. 让我们尝试一些简单的调试,以了解可能发生的情况。

I would probably try logging the form to the console first to make sure jQuery has actually found the form. 我可能会尝试先将表单记录到控制台,以确保jQuery确实找到了表单。 Just like this: console.log( $(document).find('#UploadNewImage') ); 就像这样: console.log( $(document).find('#UploadNewImage') );

If you're still having trouble it would be great of we could see the code. 如果您仍然遇到问题,那很好,我们可以看一下代码。 Give us a link to where it's hosted or use a website like jsbin or jsfiddle . 给我们提供指向其托管位置的链接,或使用jsbinjsfiddle这样的网站。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM