简体   繁体   中英

Triggering Submit in File Upload with JQuery Form Plugin

I'm using the JQuery Form Plugin for a file upload.

now, at the moment i'm using a regular submit button, but i'd much rather like to have a div trigger the submit.

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)

('#UploadNewImage' is my form)

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...

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. Just like this: 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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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