This is the output of the rest server that I need to show in the table:
{"records":[{"id":2,"name":"www.xyz.com","target":"https://www.abc.com/"},{"id":3,"name":"sample1","target":"http://www.google.com/"},{"id":4,"name":"www.aaa.com","target":"http://www.google.com/"}],"queryRecordCount":3,"totalRecordCount":3}
The JS script for dynatable is:
$(document).ready(function(){
$.ajax({
url: '/org.example.models.Domain',
success: function(data){
$('#my-table').dynatable({
dataset: {
records: data
}
});
}
});
});
When the html was loaded the my-table was rendered as a table but no data on it. What could be wrong in my code?
This does not work because dynatable accepts data in the form of JSON, and the jQuery AJAX command automatically parses (decoded) data into a JavaScript array or object.
You have two options:
dataType: 'text'
in your jQuery AJAX call, in order to stop the data being automatically parsed.