以下代码运行警报(“成功”);当它是单独的并且函数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
结束班
答案 0 :(得分:1)
这是因为您声明了函数fSuccess
,但实际上并没有实际调用它。
除此之外,你可能想要使用ajax回调,如下所示:
...
else {
alert("Success!");
//Add Server Side Function Here
.ajax({
type: "POST",
url: "Registration.aspx/Success",
success: function() { alert("Success from server"); }
});
}
...
答案 1 :(得分:0)
您只是声明该范围内的功能。您需要在定义后调用它。
fSuccess();