1

我在验证方法中调用了一个 web 服务,但是没有完成 web 服务就返回了验证方法,

代码>>

jQuery.validator.addMethod("name", function (value, element) {
    var validUsername = false;

    $.ajaxSetup({ "async": false });
    $.getJSON(serverName + '/handlers/qs-user.ashx?callback=?', {
        'username': $("#email").val(), 
        'op': 'GetMobileUser' 
        }, 
        function (data) {
            if (data.UserId == "null") {
                validUsername = true;
            } else {
                validUsername = false;
            }
        });

    $.ajaxSetup({ "async": true });
    var result = this.optional(element) || value == "" || validUsername;
    if (!result) {
        var validator = this;
        setTimeout(function () {
            validator.blockFocusCleanup = true;
            element.focus();
            validator.blockFocusCleanup = false;
        }, 1);
    }
    return result;
}, "That e-mail address has already been used.");

如何同步此 Web 服务调用 .. as

$.ajaxSetup({ "async": false });

不工作 感谢您调查此事。:)

4

0 回答 0