简体   繁体   中英

JQuery Form not submitting after uploading an image

I am making file upload control, I have a file upload control i have set its style display none and i have a button for uploading files

OnClicking the upload button i am opening fileupload' control Upload dialog, after after selecting file i have to submit the form but the form is not submitting even not any error msg is appearing,below is my code

<input type="file" id="newimg" style="display: none">
<input type="button" id="updnewimg">


  $('#updnewimg').live('click', function () {
            $('#newimg').click();
        });


 $('#newimg').change(function () {
            $("#ImgForm").submit();

        });

where ImgForm is my form's ID i've to use button here instead of submit

Can not understand why you are not doing something like this

<input type="file" id="newimg" style="display: none">
<input type="button" id="updnewimg">


  $('#updnewimg').live('click', function () {
           // any code about file upload
           $("#ImgForm").submit();
        });

EDIT
have you put the code inside a $(document).ready

$(document).ready(function() {
      $('#newimg').change(function () {
            $("#ImgForm").submit(function() {

              return false;
            });

        });
});

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