我对JavaScript有点陌生。我有一个ajax请求,它将我的json数据和位置放到一个表中,并试图集成dynatable.js。不过,我不确定最好的办法,因为我需要两者。
目前的联合来文:
$(function () {
'use strict';
//global
var current_file_index = 0;
// Initialize the jQuery File Upload widget:
$('#fileupload').fileupload({
// Uncomment the following to send cross-domain cookies:
//xhrFields: {withCredentials: true},
url: 'server/php/',
prependFiles:true
}).on('fileuploadsubmit', function (e, data) {
//data.formData = {date: data.files[0].date};
data.formData = data.context.find(':input').serializeArray();
});
// Load existing files:
$('#fileupload').addClass('fileupload-processing');
$.ajax({
// Uncomment the following to send cross-domain cookies:
//xhrFields: {withCredentials: true},
url: $('#fileupload').fileupload('option', 'url'),
dataType: 'json',
context: $('#fileupload')[0],
prependFiles:true,
}).always(function () {
$(this).removeClass('fileupload-processing');
}).done(function (result) {
$(this).fileupload('option', 'done').call(this, $.Event('done'), {result: result});
});
});Dynatable JS:
$('#remote').dynatable({
dataset: {
ajax: true,
ajaxOnLoad: true,
ajaxUrl: '/server/php/index.php',
files: []
}
});如果我把这两样都用在一起,我就会得到:
Uncaught :无法读取Records.count (jquery.dynatable.js:694) at RecordsCount.create (jquery.dynatable.js:708) at RecordsCount.attach (jquery.dynatable.js:734) at RecordsCount.init (jquery.dynatable.js:704) at Object.build (jquery.dynatable.js:186) at Object.init (jquery.dynatable.js:142) at HTMLTableElement的属性“长度”。(jquery.dynatable.js:1673) at Function.each (jquery.min.js:2) at n.fn.init.each (jquery.min.js:2) at n.fn.init.$.fn.dynatable (jquery.dynatable.js:1671)
如果我做了下面的工作,但是只是添加了搜索,0中的0等等。我尝试对表进行排序,并删除通过ajax加载的所有数据。在坚果壳中,我认为我需要更好地集成它们,使它们一起工作。
$('#remote').dynatable();发布于 2017-01-05 12:51:42
对于任何想要解决这个问题的人,请参见下面的内容:
$.ajax({
// Uncomment the following to send cross-domain cookies:
//xhrFields: {withCredentials: true},
url: $('#fileupload').fileupload('option', 'url'),
dataType: 'json',
context: $('#fileupload')[0]
}).always(function () {
$(this).removeClass('fileupload-processing');
}).done(function (result) {
$(this).fileupload('option', 'done').call(this, $.Event('done'), {result: result});
$('.table-striped').dynatable({
dataset: {
files: result,
dataType: 'text'
}
});
});https://stackoverflow.com/questions/41484752
复制相似问题