I have this little piece of code:
Use
$('form').submit(function () { window.onbeforeunload = null; });
Make sure you have this before you main submit function! (if any)