【发布时间】:2022-01-10 09:18:54
【问题描述】:
我是 Ajax 和 Js 的初学者,所以我希望我的按钮调用我的操作方法,所以这是我的脚本:
<div class="buttons">
<input type="button" class="btn btn-success" id="PassCode" value="پسورد یکبار مصرف">
</div>
$(document).ready(function () {
$("#$PassCode").click(function (e) {
var form = this;
$.ajax({
url: '@Url.Action("RenderOnetimePassword", "Customer")',
type: 'POST',
data: $(form).serialize(),
beforeSend: function () {
$("#Password").addClass("loading");
},
success: function (response) {
if (!response.success)
showError(response.message, response.captcha_string);
else if (response.url)
window.location.href = response.url;
else if (response.update_section)
$("." + response.update_section.name).html(response.update_section.html);
},
complete: function () {
$("#Password").removeClass("loading");
},
error: function (error) {
alert("@T("Account.ErrorNotification")");
}
});
}
});
在客户控制器中我有这个方法:
public ActionResult RenderOnetimePassword (SMSCodeVerificationModel model)
{
// some code here
}
我想调用我的操作,但是当我点击我的按钮时,它不起作用。
【问题讨论】:
标签: jquery ajax asp.net-mvc asp.net-ajax