jQuery - Prevent submit inside promise with post ajax validation
<p>We trying to stop form submit after an validation returned from an post. The call is inside a promise and after a confirm dialog.</p>

<p>After hours breaking my mind I couldn't make it work.</p>

<pre><code>var $form = $('#frmBoleto');

$form.submit(function(e){
    var modo = $('input[name="modo"]:checked').val();

    if (modo == 'naoimprime'){
        // Send post
        $.when( $.post($form.attr('action') + '?verifica', $form.serialize())).then(function( d ){
            if (d &amp;&amp; d.exists){
                var answer = window.confirm('You sure?');

                if (!answer){
                    e.preventDefault();
                    e.stopImmediatePropagation();
                    e.stopPropagation();
                }
            }
        });
    }
});
</code></pre>

<p>Form is always submited, why?</p>