Return False not working inside jQuery.ajax

前端 未结 7 1907
再見小時候
再見小時候 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:04

    Seems like you don't realy get the idea jQuery. You don't need to use return false, and not there. You can call event.preventDefault();:

    $('#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();
    });
    

    See this example.

提交回复
热议问题