Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 81685

sAjaxSource not working for Java servlet

$
0
0
I've got a Java servlet that is returning valid JSON data with the content type set to "application/json" (as suggested elsewhere. The JSON data looks like this (saved by going to my servlet's url):

{"sEcho":2,"iTotalRecords":2,"iTotalDisplayRecords":2,"aaData":[{"name":"Name1","value":"Value1"},{"name":"Name2","value":"Value2"}]}

My datatables declaration looks like this:

$(function(){
$('#DataTable').dataTable( {
"bProcessing": true,
"sAjaxSource": "http://localhost:8080/test.admin",
"aoColumns": [
{ "mData": "name" },
{ "mData": "value" }
]
} );
});

I can see that the data being returned is correct (breakpoint in my java code), but the datatable on my page just has "Loading..." in it and no data.

If I save the JSON data from the URL to a text file, say ajax.txt, and then set this to be the sAjaxSource, i.e. "sAjaxSource": "ajax.txt", then the page works as expected and my table is populated with two rows.

Anyone got any clues as to what might be the problem? Is it something in my java or something else?

Viewing all articles
Browse latest Browse all 81685

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>