在我的ajax响应中,我正在获取HTML内容,我想在该内容上应用数据表(该内容中的表格)。有时它有时不工作(说数据表不是函数)。
这是我的代码:
sendAjax: function(params,dataTableParams){
$('#thrbr').removeClass("dispNn");
$("#summaryResultDiv").empty();
$.ajax({
url : ajaxURL,
type : 'post',
contentType: "application/json; charset=utf-8",
data : JSON.stringify(params),
context : document.body
}).done(function(html, textStatus, request) {
$('#thrbr').addClass("dispNn");
if(html.length>0){
$("#summaryResultDiv").html(html);
$('html, body').animate({
scrollTop: $(document).height()
},
100);
setInterval($("#summaryResult").dataTable(dataTableParams),200);
}
}
});
任何输入?这里出了什么问题?我已经使用console.log()检查了dataTable()方法在加载时可用,但在ajax回调的上下文中没有。