Quantcast
Viewing all articles
Browse latest Browse all 82157

JSON Data loading with columns

Hi,

I want to load the datatables body and header from a JSON string that I get from a Spring Controller thru a Jquery Ajax call

My script looks something like this

 
$.ajax({
			type : "POST",
			url : "/mySite/getconfigdataresults",
			datatype : "json",
			data : ({
				"data" : "test"
			}),
			success : function(json) {
				alert('In Success');
				alert('The response is '+json);
				$('div#searchResults').hide();
				json.bDestroy = true;
				$('#MySearch').dataTable(json);
				$('div#searchResults').show();
			},
			error : function(e) {

				alert(e);
			}
		});


and my JSON is
{
 
"aaData": [
[ "2010-07-27 10:43:08", "..."], [ "2010-06-28 17:54:33", "..."],
[ "2010-06-28 16:09:06", "..."], [ "2010-06-09 19:15:00", "..."]
] ,
 
"aaSorting": [
 [ 1, "desc" ]
],
 
"aoColumns": [
  { "sTitle": "Title1" },
  { "sTitle": "Title2" }
]
 
}

This way of achieving it was an inspiration from a previous(currently closed ) post
http://datatables.net/forums/discussion/2529/column-definition-via-json-array-ajax/p1

The problem is i am getting a script error @ line 6542 char 11, code at that place shows

/* Set the current sorting index based on aoColumns.asSorting */
				for ( j=0, jLen=oColumn.asSorting.length ; j<jLen ; j++ )
				{
					if ( oSettings.aaSorting[i][1] == oColumn.asSorting[j] )
					{
						oSettings.aaSorting[i][2] = j;
						break;
					}
				} 

The error says
'asSorting' is null or not an object.

I am running on a v 1.9.2 js

Any help is greatly appreciated

Viewing all articles
Browse latest Browse all 82157

Trending Articles