Return False not working inside jQuery.ajax

前端 未结 7 1903
再見小時候
再見小時候 2021-02-08 17:38

P.S.: Read \"EDITED on 2019-06-29\":

I have a webform for updating user information, and when he updates his email a verification is performed via

7条回答
  •  野性不改
    2021-02-08 18:15

    you should use event.preventDefault() as shown below.

    $('#form').submit(function(event) {
        $.get('/ajax/verify-email.php?email=' + $('#email').val(), function(d) {
            if (d == '1') {
                alert('Another user is using this email');
                $('#email').focus();
                event.preventDefault();
            }
        });   
    });
    

提交回复
热议问题