I don't konw how to load the another JSON data, please help
I don't konw how to load the another JSON data, please help
i know how to load a json data which format like:
{ "aaData": [
["USA","300,000","880","2011","cc","/217180/2C1CDB7C5E96CD52C.JPG"]
] }
but i try many times, i still don't understand how to load a json data format like:
{"aaData": [
{
"area":"usa",
"size":"300,000",
"street_num":"880",
"year":"2011",
"icon_path":"/217180/2C1CDB7C5E96CD52C.JPG"
}
]}
Please help!!
I have a look a example http://datatables.net/release-datatables/examples/server_side/post.html
but i don't know "scripts/post.php" this file's path, and it can't be run in my localhost, which i download from the "DataTables-1.9.0.rar"
{ "aaData": [
["USA","300,000","880","2011","cc","/217180/2C1CDB7C5E96CD52C.JPG"]
] }
but i try many times, i still don't understand how to load a json data format like:
{"aaData": [
{
"area":"usa",
"size":"300,000",
"street_num":"880",
"year":"2011",
"icon_path":"/217180/2C1CDB7C5E96CD52C.JPG"
}
]}
Please help!!
I have a look a example http://datatables.net/release-datatables/examples/server_side/post.html
but i don't know "scripts/post.php" this file's path, and it can't be run in my localhost, which i download from the "DataTables-1.9.0.rar"
This discussion has been closed.
Replies
have you set "aoColumns" at initialization?
[code]
[{"mDataProp":"area"},{"mDataProp":"size"},{"mDataProp":"street_num"},{"mDataProp":"year"},{"mDataProp":"icon_path"}]
[/code]
thank u for ur helping,
i set "aoColumns" at initialization, but it doesn't work and return a datatable warning:
DataTables warning: JSON data from server could not be parsed. This is caused by a JSON formatting error
Allan
$('#example').dataTable( {
"aoColumns":[{"mDataProp":"area"},{"mDataProp":"building_name"},{"mDataProp":"street_num"},{"mDataProp":"build_sqft"},{"mDataProp":"icon_path"}],
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": 'posts.php'
} );
posts.php content:
<?php
$json='
{"searchresults": [
{
"area":"usa",
"building_name":"First",
"street_name":"street one",
"build_sqft":"1000",
"icon_path":"http://farm8.staticflickr.com/7016/6835796043_f7275cf2cb_m.jpg"
},
{
"area":"Canda",
"building_name":"Two",
"street_name":"street two",
"build_sqft":"1500",
"icon_path":"http://farm8.staticflickr.com/7016/6835796043_f7275cf2cb_m.jpg"
},
{
"area":"Aus",
"building_name":"Third",
"street_name":"street three",
"build_sqft":"2000",
"icon_path":"http://farm8.staticflickr.com/7016/6835796043_f7275cf2cb_m.jpg"
}
]}
';
echo $json;
I check the return JSON through http://jsonlint.com, the result is Valid JSON
"sEcho": 3,
"iTotalRecords": 2,
"iTotalDisplayRecords": 2,
in the json title and set "aoColumns" at initialization.
^.^
Allan
i have corrected the the json data name to aaData,
it load the json data is ok, but can't be sort and search in the datatable default sorting and searching
Help!!
{
var aData = oTable.fnGetData( nTr );
var sOut = '';
sOut += 'Rendering engine:'+aData[1]+' '+aData[4]+'';
sOut += 'Link to source:Could provide a link here';
sOut += 'Extra info:
i delete "bServerSide": true, the datatable's sorting and searching become work, but i don't know the reason.
Sounds like you want client-side processing though, so yes, removing bServerSide is the correct thing to do.
Allan