創建表我嘗試檢索的數據來創建表的tablesorter喜歡這裏:的tablesorter從阿賈克斯
http://mottie.github.io/tablesorter/docs/example-widget-build-table.html(章節:「設置 - 對象(javascript變量)」)
的HTML代碼(簡單DIV):
<div id="list_user"></div>
這裏是JS腳本:
jQuery(document).ready(function() {
function get_users_list(){
return $.post(
"/mysql/function_users.php",
{
'type_request' : 'list_users'
},
"json"
);
};
get_users_list().done(function(data){
return data;
});
$(document).ajaxComplete(function(event,request, settings) {
if (settings.url == "/mysql/function_users.php") {
var dataOject = request.responseText;
alert(dataOject);
$('#list_user').tablesorter({
debug:true,
theme : 'blue',
sortList: [[0,0]],
widthFixed: false,
widgets: ['zebra','filter'],
data : dataOject,
widgetOptions : {
build_objectRowKey : 'rows',
build_objectHeaderKey : 'headers',
filter_hideEmpty : false
}
});
};
});
});
當我檢查什麼是PHP腳本「function_users.php」,我得到以下結構返回:
{
"headers":[
[
"Name",
"Surname",
"email",
"region",
"date creation",
"last modification",
{"text":"","class":"not_sort filter-false toclean"},
{"text":"","class":"not_sort filter-false toclean"},
{"text":"","class":"not_sort filter-false toclean"}
]
],
"rows":[
["toto","toto","[email protected]","latam","1410142447","1410142537"],
["tata","tata","[email protected]","emea","1410142447","1410142537"],
["titi","titi","[email protected]","asia","1410142447","1410142537"],
["tutu","tutu","[email protected]","latam","1410142447","1410142537"]
]
}
如果您有任何鉛請。謝謝