Hi guys, I have a simple form that is sent when the user clicks the open button in the file view after completing the image selection.
My HTML looks somehow below.
<form id="imgForm" action="action.php" method="post" enctype="multipart/form-data"> <div class="fileUpload btn btn-lg btn-primary"> <span>Choose File</span> <input id="imageToBeUploaded" type="file" class="upload" name="image"/> </div> </form>
Javascript
$("body").on('submit', '#imgForm', function(){ $(this).ajaxForm({target:'#uploadStatus'}); console.log("submitting..."); return false; }); $('body').on('change','#imageToBeUploaded', function() {
My problem is that the form submits but is redirected to the action.php page with the response. I was hoping to stop redirects, but instead return a response to the current page. return false; doesn't seem to work as per the documentation at http://malsup.com/jquery/form/#ajaxSubmit
Any help would be greatly appreciated!
Please note that I need to support IE8 / 9, which means that formData is out of the question!
Thanks.
javascript jquery html ajaxform
Baconjuice
source share