I'm trying to override the form submit to send an ajax request
but it is not working.
when i simply call submit()
the page gets redirected.
I'm trying to implement something like this.
could it be a jquery version problem or i'm using it wrong.
this is my try :
$('#fileUploadField').on("change", function() {
$("#upload_file").submit(function(e) {
alert("override");
e.preventDefault();
});
});
.hidden2{
margin:0;
padding:0;
position: absolute;
top: 0;
right: 0;
height: 100%;
font-size: 50px;
cursor: pointer;
opacity: 0;
-moz-opacity:0;
filter: Alpha(Opacity=0);
}
img.fileDownload
{
height: 26px;
width: 26px;
padding: 0;
display: inline-block;
vertical-align: middle;
margin: 0 4px 0 0;
cursor: pointer;
position: absolute;
top: 0;
left: 0;
}
div.hiddenFileInputContainter
{
position: relative;
display: inline-block;
width: 27px;
height: 27px;
overflow: hidden;
vertical-align: middle;
cursor: pointer;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<form id="upload_file" action="upload.php" method="post" enctype="multipart/form-data">
<div class="hiddenFileInputContainter">
<img class="fileDownload" src="http://b.dryicons.com/images/icon_sets/coquette_part_2_icons_set/png/128x128/attachment.png" width="10" height="10">
<input id="fileUploadField" type="file" name="uploaded_file" class="hidden2">
</form>