jQuery form submit

后端 未结 4 2000
终归单人心
终归单人心 2020-12-15 08:49

My goal is: When for is submitted:

  • a validation on form is made : OK
  • an ajax is called to see that username and password do match : OK<
4条回答
  •  一向
    一向 (楼主)
    2020-12-15 09:33

    You can call the native submit event, so do this:

    $('#form1').submit(form1Submit);
    

    Then in your post callback do this:

    $.post("check.php", { username: username, password:password }, function(data) {
        if (data=="ko") {
            alert('bad password');
        } else {
            this.submit();
        }
    });
    

    The this.submit() isn't calling he jQuery .submit() trigger function, but rather the native

    .submit() function.

提交回复
热议问题