json no loading
json no loading
Hi,
I'm looking to see if I can use DataTables... So I´m trying to use the .getJSON. The Json I´m getting is valid according to JSONLint. I can see in Firebug that the it loads and I see the response (which I validated) However there is nothing visible in the DataTables, all I see is Processing.
[code]
$(document).ready(function () {
$('#example').dataTable({
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "/field/getFields",
"fnServerData": function (sSource, aoData, fnCallback) {
/* Add some extra data to the sender */
aoData.push({ "name": "more_data", "value": "my_value" });
$.getJSON(sSource, aoData, function (json) {
/* Do whatever additional processing you want on the callback, then tell DataTables */
fnCallback(json)
});
}
});
});
[/code]
So I´m wondering what could be wrong, and how to debug ?
Regards
Arro
I'm looking to see if I can use DataTables... So I´m trying to use the .getJSON. The Json I´m getting is valid according to JSONLint. I can see in Firebug that the it loads and I see the response (which I validated) However there is nothing visible in the DataTables, all I see is Processing.
[code]
$(document).ready(function () {
$('#example').dataTable({
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "/field/getFields",
"fnServerData": function (sSource, aoData, fnCallback) {
/* Add some extra data to the sender */
aoData.push({ "name": "more_data", "value": "my_value" });
$.getJSON(sSource, aoData, function (json) {
/* Do whatever additional processing you want on the callback, then tell DataTables */
fnCallback(json)
});
}
});
});
[/code]
So I´m wondering what could be wrong, and how to debug ?
Regards
Arro
This discussion has been closed.
Replies
Allan
[code]
{"page":1,"total":4,"rows":[{"id":"1000","cell":["1000","Vestur","Fj
You can see this in action using the server-side processing example and looking at the XHR's as they come through in Firebug.
Allan
thanks for pointing this out to me, anyways I changed the JSON see
[code]
{
"sEcho": 1,
"iTotalRecords": 4,
"iTotalDisplayRecords": 4,
"aaData": [
{
"id": "1000",
"cell": [
"1000",
"Vestur",
"Fj
Here is an example of a valid JSON return from one of my projects as shown here.
Get it to look like this and you will be good to go!
[code]
{
"sEcho": 3,
"iTotalRecords": 186,
"iTotalDisplayRecords": 3,
"aaData": [
[
"td 1",
"td 2",
"td 3",
"td 4",
"td 5"
],
[
"td 1",
"td 2",
"td 3",
"td 4",
"td 5"
],
[
"td 1",
"td 2",
"td 3",
"td 4",
"td 5"
]
]
}
[/code]