$(document).ready(function() {
var selected;
var selectedOutput;
var template;
var submitButton;
var insertedTable = $('#pkgLineTable').dataTable({
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"bPaginate": true,
"bLengthChange": true,
"bFilter": true,
"bSort": false,
"bInfo": true,
"bAutoWidth": false,
"bProcessing": true,
"bServerSide": false,
"sAjaxSource": '@{Overview.getPkgLineList()}',
"fnServerData": fnServerObjectToArray(['shortname', 'description'])
});
});
fnServerObjectToArray = function (aElements) {
return function (sSource, aaData, fnCallback) {
$.ajax({
"dataType": 'json',
"type": "GET",
"url": sSource,
"data": aaData,
"success": function (json) {
var a = [];
$.each(json, function(index, item) {
var inner = [];
for (var i = 0, iLen = aElements.length; i < iLen; i++) {
inner.push(item[aElements[i]]);
}
a.push(inner);
});
json.aaData = a;
fnCallback(json);
}
});
}
}
答案 0 :(得分:1)
如果要在图像完成后加载ajax,请使用load代替.ready:
$(window).load(function() {
var selected;
var selectedOutput;
var template;
var submitButton;