Form submit with input type=submit doesn't trigger $.post in js
I have a form for downloading a file: when i fill with specific data i click "download" because take about 2 min to prepare document for download, i display a message with "please wait". After download completes the message disappears. What i did: i have an <input type="submit" id="form" onClic="myFunc();"> // i tried with return myFunc(); too and an ajax post (because js doesn't download file, is there only for callback function).
function myFunc(){ alert("Here1!"); $.ajax({ type: 'POST', url: $("#form").attr('action') + "?download=download", data: $("#form").serialize(), success: function(response){ alert("Here2!"); stopCursorWait(); }}); }
On chrome, IE, Opera there are two post in network debugger : one from the form and one from the ajax - everything works fine On FireFox there is only one submit (from the form).
Is there any solution to capture response from form submitting? I tried other solutions, like:
$("#form").bind('ajax:complete', function() { alert("here!");
stopCursorWait();
}
or
$(document).ajaxComplete(function( event,request, settings ) {
stopCursorWait();
});
Any of these doesn't work. I just want to have "please wait" message for the entire time of preparing and downloading process.