我试图将数据存储在本地存储上并在数据表中使用该数据...
JSON DATA
{
"items": [{
"id": "0",
"itemcode": "/0002100ADAM",
"desc": "No Problem Found",
"price": "45.0000"
}, {
"id": "1",
"itemcode": "/0002100DIX-",
"desc": "No Problem Found",
"price": "45.0000"
}, {
"id": "2",
"itemcode": "/0009010BRN-",
"desc": "Return with Part",
"price": "50.0000"
}, {
"id": "3",
"itemcode": "/0009010DIX-",
"desc": "Return with Part",
"price": "50.0000"
}, {
"id": "4",
"itemcode": "/100-AA",
"desc": "Standard Gadget",
"price": "66.0000"
}, {
"id": "5",
"itemcode": "/1NOCLLLLDIXT",
"desc": "No Charge Labor Code",
"price": "55.0000"
}, {
"id": "6",
"itemcode": "/200-DA",
"desc": "22\" Widget with Hinges",
"price": "25.0000"
}, {
"id": "7",
"itemcode": "/287-GA",
"desc": "19\" Gadget with Wheels",
"price": "75.0000"
}],
"state": true
}
的JavaScript
var restoredSession = JSON.parse(localStorage.getItem('session'));
$('#itemlookdata').html( '<table cellpadding="0" cellspacing="0" border="0" class="display" id="example"></table>' );
$('#example').dataTable({
aaData : restoredSession,
"aoColumns": [
{ "mData": "id" },
{ "mData": "itemcode" },
{ "mData": "desc" },
{ "mData": "price" }
]
});