I am working with jQuery file upload plugin. Here, I tried to update an existing image:
$(document).ready(function() {
var options = {
target: '#notification_img', // target element(s) to be updated with server response
beforeSubmit: beforeSubmit, // pre-submit callback
success: afterSuccess, // post-submit callback
resetForm: true // reset the form after successful submit
};
$('#MyImg').submit(function() {
$(this).ajaxSubmit(options);
// always return false to prevent standard browser submit and page navigation
return false;
});
html form
<form action="img_up.php" method="post" enctype="multipart/form-data" id="MyImg">
<label>Upload Photo</label><br>
<input class="inp" id="photo-up" type="file" placeholder="Photo" name="photo-up"/><br/>
<input class="btn" type="submit" id="update-img-btn" value="Update" /><br/>
<img src="images/ajax-loader.gif" id="loading-img" style="display:none; text-align:center;" alt="Please Wait"/>
</form>
My problem is this page is redirecting to the img_up.php
file when I am submitting the form. But this is not suppose to happen as I am using AJAX. The image is not uploading in to the directory. I have included all the required JavaScript files.