如果我点击按钮,Jquery Ajax 调用只会触发一次,它会返回最后返回的响应,但不会去 c# 中的 ajax 函数这是我的 aspx 代码
<asp:ImageButton ID="iBtnSaveUser" runat="server" OnClientClick="return ValidateForm();" />
这是我的 jquery Ajax 函数
function ValidateForm() {
if ($(txtName).val() == "") {
alert('Name Required');
return false;
}
else if ($(txtUserName).val() == "") {
alert('UserName Required');
return false;
}
else if ($(txtPassword).val() == "") {
alert('Password Required');
return false;
}
else if ($(txtEmail).val() == "") {
alert('Email Required');
return false;
}
else if ($(txtPhone).val() == "") {
alert('Phone Number Required');
return false;
}
else if ($(ddlProfile).val() == "") {
alert('Profile Required');
return false;
}
AddUser();
return false;
}
function AddUser() {
var name = $(txtName).val();
var userName = $(txtUserName).val();
var password = $(txtPassword).val();
var email = $(txtEmail).val();
var phone = $(txtPhone).val();
var profile = $(ddlProfile).val();
$.ajax({
type: "GET",
url: ajaxCallHandlerUrl,
data: { OpCode: "AddUser", Params: "Name^" + name + "~UserName^" + userName + "~Email^" + email + "~Phone^" + phone + "~Profile^" + profile +"~Password^"+password },
dataType: "",
success: function (responseString) {
alert(responseString);
}
});
}