php - jquery using .submit() form not submitting -


i submitting form using jquery when use javascript submitted through jquery not submitting.

here form code:

<form method="post" id="uploadfrm" action="<?php echo site_url('filemanager/upload'); ?>" enctype="multipart/form-data" > <div class="up_wraper">click here select file </div> <input type="file" name="upload[]" id="upload" multiple="multiple" /> </form>    

jquery code:

<script type="text/javascript">    $(document).ready( function() {        $("#upload").change( function() {          var value=$("#foo").val();         var file=$("#upload").val();         var arr = value.split("_");         var id = arr[1];         var type = arr[0];          if(type!='folder'){             alert('select folder upload files..!');             }           else{                  $("#foo").val(id);                  $('#uploadfrm').submit( function(event) {                  event.preventdefault();                   });              }        });    }); </script> 

when use in else condition:

document.forms["uploadfrm"].submit(); 

it submits successfully.

but want submit using jquery using preventdefault() method.

in code have this...

$('#uploadfrm').submit( function(event) {     event.preventdefault(); }); 

the 2nd line, event.preventdefault();, stops form submitting. if remove submit fine. this...

$('#uploadfrm').submit(); 

Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -