0

下面的代码运行 alert("Success"); 当它单独并且函数 fSuccess 被注释掉时,它不会触发 fSuccess() 函数。这是为什么?非常感谢您的参与。

$.when(chkUsername(), chkPassword()).done(function () {
                if (boolusername == 0) {
                    $("#ErrorUN").css("display", "block");
                }
                else {
                    if (boolpassword == 0) {
                        $("#ErrorP").css("display", "block");
                    }
                    else {
                        $.ajax({
                            type: "POST",
                            url: "Registration.aspx/Success",
                            data: "{}",
                            contentType: "application/json; charset=utf-8",
                            dataType: "json",
                            success: function () { }
                        });
                    }
                }
            }); //when





Imports System.Web.Services

Public Class Registration
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub

<WebMethod()>
Public Shared Sub Success()

   Dim strBreakPoint As String = "qwerty"

End Sub

结束类

4

2 回答 2

1

这是因为您声明了函数fSuccess,但从未真正调用它。

除此之外,您可能还想使用 ajax 回调,如下所示:

...
else {
    alert("Success!");
    //Add Server Side Function Here
    .ajax({
        type: "POST",
        url: "Registration.aspx/Success",
        success: function() { alert("Success from server"); }
    });
}
...
于 2013-02-27T17:50:04.473 回答
0

您只是在该范围内声明函数。您需要在定义后调用它。

fSuccess();
于 2013-02-27T17:50:56.893 回答