我的视图上有一个按钮链接,如下所示:
<a href="@Url.Action("ActionName", "ControllerName", new { id = Model.Id})" id="My-Btn" class="btn btn-info pull-right" data-role="button">Go Somewhere</a>
现在,我在页面上使用ajax向WebApi控制器方法提交值,并且当我这样做时,我希望禁用按钮链接。这是我的ajax:
$.ajax({
url: myUrl,
method: "DELETE",
beforeSend: function () {
disableSendButton();
},
success: function() {
row.remove();
toastr.options = {
onHidden: function () {
window.location.href = redirectUrl;
},
timeOut: 2000
}
toastr.success("Success.");
}
});
function disableSendButton() {
$("#My-Btn").addClass("ui-disabled");
}
这对我不起作用。在ajax调用期间,该按钮仍然处于活动状态。如何在ajax调用期间禁用此按钮?
使用
$("#My-Btn").prop('disabled', true).addClass("disabled");
并添加 CSS
.disabled{
cursor: not-allowed;
}
这会将禁用的光标置于按钮上。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句