$(this)在Ajax里失效的问题
$('button').click(function () {
let inputValue = $(this).prev().val();
let $this = $(this);// 绑定$(this)
if (inputValue) {
$.ajax({
url: "",
type: "post",
data: {},
dataType: 'json',
success: function (data) {
if (data.statusCode == 200) {
$(this).prop('disabled',true);// 这里的$(this)指向是Ajax,本意是要给button加disabled
$this.prop('disabled',true);// 需要在Ajax外部绑定$(this)
} else {
}
}, error: function (data) {
console.log("错误" + data);
}
});
} else {
layer.msg('提成不能为空', {icon: 2});
}
});