Using json var as sajaxsource :/
Using json var as sajaxsource :/
Hi everyone, really struggling to get my head round this but I am sure it is simple, making it even more frustrating...
I have pasted an exampled below but in summary, I am using $.merge to join two json sources to load into datatables. This part is working as i have checked the results of the merge and it is joining correctly. However, datatables will not load the data. Can anyone see why?? Even if i select just one of the variables before any merging it still does not populate. Appreciate any help.
var dataset = {"posts":[{"d":"Three.gif,24,7.87","M":"0","T":"0","D":"1.00","I":"188.88,0.00,","P":"0.00","O":"7.87","l":"xxxxx,17.gif"}]};
var append = {"posts":[{"d":"Three.gif,24,15.99","M":"0","T":"0","D":"15.00","I":"271.83,0.00,","P":"0.00","O":"11.33","l":"t\/a\/MCC\/URMOB-xmakex-xmodelx-xtariffx\/track.php%253fid=4191930,6.gif"},{"d":"Three.gif,18,10.49","M":"0","T":"0","D":"1.00","I":"208.81,0.00,","P":"19.99","O":"11.60","l":"xxxxxx,6.gif"}]};
dataset === $.merge(dataset.posts, append.posts);
var myObject = JSON.stringify(dataset);
$(document).ready( function () {
$('#example').dataTable( {
"bProcessing": true,
"sAjaxSource": dataset,
"bDeferRender": true,
"bSortClasses": false,
"sAjaxDataProp": "posts",
"bFilter": true,
"sDom": '<"top">rt<"bottom"ip><"clear">',
"iDisplayLength": 9,
I have pasted an exampled below but in summary, I am using $.merge to join two json sources to load into datatables. This part is working as i have checked the results of the merge and it is joining correctly. However, datatables will not load the data. Can anyone see why?? Even if i select just one of the variables before any merging it still does not populate. Appreciate any help.
var dataset = {"posts":[{"d":"Three.gif,24,7.87","M":"0","T":"0","D":"1.00","I":"188.88,0.00,","P":"0.00","O":"7.87","l":"xxxxx,17.gif"}]};
var append = {"posts":[{"d":"Three.gif,24,15.99","M":"0","T":"0","D":"15.00","I":"271.83,0.00,","P":"0.00","O":"11.33","l":"t\/a\/MCC\/URMOB-xmakex-xmodelx-xtariffx\/track.php%253fid=4191930,6.gif"},{"d":"Three.gif,18,10.49","M":"0","T":"0","D":"1.00","I":"208.81,0.00,","P":"19.99","O":"11.60","l":"xxxxxx,6.gif"}]};
dataset === $.merge(dataset.posts, append.posts);
var myObject = JSON.stringify(dataset);
$(document).ready( function () {
$('#example').dataTable( {
"bProcessing": true,
"sAjaxSource": dataset,
"bDeferRender": true,
"bSortClasses": false,
"sAjaxDataProp": "posts",
"bFilter": true,
"sDom": '<"top">rt<"bottom"ip><"clear">',
"iDisplayLength": 9,
This discussion has been closed.
Replies
Allan
Although one thing - is there any way I can get aaData to work with the dataset above? I had to remove {"posts": from the beginning and } from the end in order to get it to load, apart from changing my source data can i change something on datatable config?
Thanks :)
aaData: dataset.posts
[/code]
looks like it should do it.
Allan