代码是:
$.ajax({
type: "POST",
url: '@Url.Action("getFilterActiveData")',
dataType: "json",
mtype: "post",
traditional: true,
data: {
values: arg
},
async: true,
beforeSend: function () {
$("#filter tr").live('click', function () {
document.getElementById('filter_btn').style.pointerEvents = 'none';
});
$('#filter_loading').fadeIn();
},
success: function (data) {
$('#filter_loading').fadeOut();
$("#filter tr").live('click', function () {
alert("does not shown");
if (isSection == false) {
$('#filter_btn').click().promise().done(function () {
document.getElementById('filter_btn').style.pointerEvents = 'auto';
});
}
});
}
});
alert
未显示,但如果我直接写出AJAX的一面,如:
$("#filter tr").click(function () {
alert("clicked " + isSection);
然后它会显示出来。有什么建议吗?我可以创建一个将成功调用的函数,但我不知道在beforeSend()
答案 0 :(得分:0)
试试这个,live方法很久以前就已经折旧了。您可以使用$.on()
,$.bind()
或类似内容来代替直播。
$.ajax({
type: "POST",
url: 'file url',
dataType: "json",
method : "post",
data: { values: arg },
async: true,
beforeSend: function(){
$("#filter tr").on('click', function () {
document.getElementById('filter_btn').style.pointerEvents = 'none';
});
$('#filter_loading').fadeIn();
},
success: function (data) {
$('#filter_loading').fadeOut();
$("#filter tr").click(function () {
alert("does not shown");
if (isSection == false) {
$('#filter_btn').click().promise().done(function () {
document.getElementById('filter_btn').style.pointerEvents = 'auto';
}
});
}
});