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
Post a Comment