I am submitting a form using jQuery but when I use JavaScript it is submitted but through jQuery it is not submitting.
Here is my form code:
<form method="post" id="uploadfrm" action="<?php echo site_url('filemanager/upload'); ?>" enctype="multipart/form-data" >
<div class="up_wraper">Click here to Select a 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 a folder to upload files..!');
}
else{
$("#foo").val(id);
$('#uploadfrm').submit( function(event) {
event.preventDefault();
});
}
});
});
</script>
When I use in else condition:
document.forms["uploadfrm"].submit();
it submits successfully.
But I want to submit it using jQuery using preventDefault() method.
event.preventDefault();and the form will submit i think.