Ajax example help
Ajax example help
Having issue using the datatable and ajax combination
[quote]JJson response is below [/quote]
[code] {"aaData":[{"dateModified":"2013-07-31T20:22:03.043","ticketId":"2802662","dateOpened":"2013-07-31T20:22:03.043","siteId":"603107","status":"Open - Solving","address":"1 Bhongir Pkwy, Town and Country, 63017","subject":"BhongirStation Portal","priority":"3 - Medium","reportedBy":"Ryan Becker","dateClosed":"","type":"Incident","siteName":"BhongirStation Integration Testing"},{"dateModified":"2013-07-31T20:22:03.043","ticketId":"2802662","dateOpened":"2013-07-31T20:22:03.043","siteId":"603107","status":"Open - Solving","address":"1 Bhongir Pkwy, Town and Country, 63017","subject":"BhongirStation Portal","priority":"3 - Medium","reportedBy":"Ryan Becker","dateClosed":"","type":"Incident","siteName":"BhongirStation Integration Testing"},{"dateModified":"2013-07-31T20:22:03.043","ticketId":"2802662","dateOpened":"2013-07-31T20:22:03.043","siteId":"603107","status":"Open - Solving","address":"1 Bhongir Pkwy, Town and Country, 63017","subject":"BhongirStation Portal","priority":"3 - Medium","reportedBy":"Ryan Becker","dateClosed":"","type":"Incident","siteName":"BhongirStation Integration Testing"},{"dateModified":"2013-07-31T20:22:03.043","ticketId":"2802662","dateOpened":"2013-07-31T20:22:03.043","siteId":"603107","status":"Open - Solving","address":"1 Bhongir Pkwy, Town and Country, 63017","subject":"BhongirStation Portal","priority":"3 - Medium","reportedBy":"Ryan Becker","dateClosed":"","type":"Incident","siteName":"BhongirStation Integration Testing"},{"dateModified":"2013-07-31T20:22:03.043","ticketId":"2802662","dateOpened":"2013-07-31T20:22:03.043","siteId":"603107","status":"Open - Solving","address":"1 Bhongir Pkwy, Town and Country, 63017","subject":"BhongirStation Portal","priority":"3 - Medium","reportedBy":"Ryan Becker","dateClosed":"","type":"Incident","siteName":"BhongirStation Integration Testing"}]} [/code]
[quote]JDatatable code [/quote]
[code] $(document).ready( function () {
var oTable = $('#myTable').dataTable( {
"sAjaxSource": '${mainURL}',
"sServerMethod": "POST",
"aoColumns": [
{ "mData": "ticketId" },
{ "mData": "siteId" },
{ "mData": "siteName"},
{ "mData": "address" },
{ "mData": "reportedBy" },
{ "mData": "type"},
{ "mData": "status" },
{ "mData": "priority" },
{ "mData": "subject" },
{ "mData": "dateOpened" },
{ "mData": "dateClosed" },
{ "mData": "dateModified" }
],
"bScrollInfinite": true,
"bScrollCollapse": true,
"sScrollY": ($(window).height() - 350),
"oLanguage": {"sInfo": "Total records: _TOTAL_" }
} );//datatable
} );
[/code]
[quote]JJson response is below [/quote]
[code] {"aaData":[{"dateModified":"2013-07-31T20:22:03.043","ticketId":"2802662","dateOpened":"2013-07-31T20:22:03.043","siteId":"603107","status":"Open - Solving","address":"1 Bhongir Pkwy, Town and Country, 63017","subject":"BhongirStation Portal","priority":"3 - Medium","reportedBy":"Ryan Becker","dateClosed":"","type":"Incident","siteName":"BhongirStation Integration Testing"},{"dateModified":"2013-07-31T20:22:03.043","ticketId":"2802662","dateOpened":"2013-07-31T20:22:03.043","siteId":"603107","status":"Open - Solving","address":"1 Bhongir Pkwy, Town and Country, 63017","subject":"BhongirStation Portal","priority":"3 - Medium","reportedBy":"Ryan Becker","dateClosed":"","type":"Incident","siteName":"BhongirStation Integration Testing"},{"dateModified":"2013-07-31T20:22:03.043","ticketId":"2802662","dateOpened":"2013-07-31T20:22:03.043","siteId":"603107","status":"Open - Solving","address":"1 Bhongir Pkwy, Town and Country, 63017","subject":"BhongirStation Portal","priority":"3 - Medium","reportedBy":"Ryan Becker","dateClosed":"","type":"Incident","siteName":"BhongirStation Integration Testing"},{"dateModified":"2013-07-31T20:22:03.043","ticketId":"2802662","dateOpened":"2013-07-31T20:22:03.043","siteId":"603107","status":"Open - Solving","address":"1 Bhongir Pkwy, Town and Country, 63017","subject":"BhongirStation Portal","priority":"3 - Medium","reportedBy":"Ryan Becker","dateClosed":"","type":"Incident","siteName":"BhongirStation Integration Testing"},{"dateModified":"2013-07-31T20:22:03.043","ticketId":"2802662","dateOpened":"2013-07-31T20:22:03.043","siteId":"603107","status":"Open - Solving","address":"1 Bhongir Pkwy, Town and Country, 63017","subject":"BhongirStation Portal","priority":"3 - Medium","reportedBy":"Ryan Becker","dateClosed":"","type":"Incident","siteName":"BhongirStation Integration Testing"}]} [/code]
[quote]JDatatable code [/quote]
[code] $(document).ready( function () {
var oTable = $('#myTable').dataTable( {
"sAjaxSource": '${mainURL}',
"sServerMethod": "POST",
"aoColumns": [
{ "mData": "ticketId" },
{ "mData": "siteId" },
{ "mData": "siteName"},
{ "mData": "address" },
{ "mData": "reportedBy" },
{ "mData": "type"},
{ "mData": "status" },
{ "mData": "priority" },
{ "mData": "subject" },
{ "mData": "dateOpened" },
{ "mData": "dateClosed" },
{ "mData": "dateModified" }
],
"bScrollInfinite": true,
"bScrollCollapse": true,
"sScrollY": ($(window).height() - 350),
"oLanguage": {"sInfo": "Total records: _TOTAL_" }
} );//datatable
} );
[/code]
This discussion has been closed.
Replies
but getting the following error
[quote]
Datatables warning( table id='myTable') : Requested unknown parameter '0' from the data source for row 0
[/quote]
It sounds like you have more columns in the HTML than you do in the aoColumns array. But without a test case, I'm guessing.
Allan