Last active
August 29, 2015 14:05
-
-
Save RimonEkjon/0a9ac7068a0fac396a90 to your computer and use it in GitHub Desktop.
Ajax Image upload without refreshing the form
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form action="processupload.php" method="post" enctype="multipart/form-data" id="MyUploadForm"> | |
<input name="ImageFile" id="imageInput" type="file" /> | |
<input type="submit" id="submit-btn" value="Upload" /> | |
<img src="images/ajax-loader.gif" id="loading-img" style="display:none;" alt="Please Wait"/> | |
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function() { | |
var options = { | |
target: '#output', | |
beforeSubmit: beforeSubmit, | |
success: afterSuccess, | |
resetForm: true | |
}; | |
$('#MyUploadForm').submit(function() { | |
$(this).ajaxSubmit(options); | |
return false; | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment