我的onclick jquery,
$(document).ready(function () {
$("#submitSave").on("click", function () {
var confirmPassword = $("#txtLgnPasswordConfirmReset").val();
var passwordReset = {
UserName: $("#txtLgnUsername").val(),
Password: $("#hdnOldPassword").val(),
NewPassword: $("#txtLgnPasswordReset").val()
}
$.ajax({
type: "POST",
url: "/Account/PasswordReset",
data: passwordReset
});
});
});
下面是我的Controller动作方法,上面的jquery,
在'ON CLICK'上调用[HttpPost]
public ActionResult PasswordReset(User user)
{
if (_lfAPI.PasswordReset(user))
{
return RedirectToRoute(Constants.Login);
}
return View();
}
如果my,if(condition)在上面的方法中返回true,我想显示一条通知消息...... 我的通知消息,
notifyMessage.showNotifyMessage('info', 'Your password has been reset.Please login with your new password.', false)
提前致谢...
答案 0 :(得分:2)
你可以在ajax成功回调中处理这个
$.ajax({
type: "POST",
url: "/Account/PasswordReset",
data: passwordReset,
success: function(data) {
if (data == true) {
//show success msg
}
}
});

答案 1 :(得分:0)
在ajax调用中使用成功回调。
$.ajax({
type: "POST",
url: "/Account/PasswordReset",
data: passwordReset ,
success: function (resp) {
if (resp == "true") {
// do your stuff here
notifyMessage.showNotifyMessage('info', 'Your password has been reset.Please login with your new password.', false)
}
},
});
});