Hi Allen, etc. al.,
I am mocking a server-side call using Mockjax and MockJson with a Twitter Bootstrap themed data table. My mock json package appears fine, however, data never binds to the DataTable. After a day of reviewing the docs and forum threads, I still don't see what the problem is. My code is below for review. Thank you in advance for any assistance you can provide.
I am mocking a server-side call using Mockjax and MockJson with a Twitter Bootstrap themed data table. My mock json package appears fine, however, data never binds to the DataTable. After a day of reviewing the docs and forum threads, I still don't see what the problem is. My code is below for review. Thank you in advance for any assistance you can provide.
/* Mock Data ---------------------------------------------*/ $.mockjaxSettings = { status: 200, responseTime: 300, isTimeOut: false, contentType: 'application/json; charset=utf-8', response: '', responseText: '', responseXml: '', proxy: '', lastModified: null, etag: '' } $.mockjax({ url: 'http://api.gravycard.com/v1/promoter/emp/history.json' , dataType: 'json', responseText: $.mockJSON.generateFromTemplate({ 'aaData|50-50': [{ 'empName': '@FEMALE_FIRST_NAME' + ' ' + '@LAST_NAME', 'empTitle|10-30': '@LETTER_UPPER', 'empTelephone|10-10': '@NUMBER', 'empRole|10-10': '@LOREM_IPSUM', 'empNumPromos|1-3': '@NUMBER' }], 'sEcho': 1, 'iTotalRecords': 50, 'iTotalDisplayRecords': 50 }) }); $(function() { $.getJSON("http://api.gravycard.com/v1/promoter/emp/history.json", function(data) { alert(JSON.stringify(data)); }); $('#dynamicTbl').dataTable({ "sDom": "<'row'<'span6'l><'span6'f>r>t<'row'<'span6'i><'span6'p>>", "bPaginate": true, "sPaginationType": "bootstrap", "oLanguage": { "sLengthMenu": "" // Empty $ = Disable 'Records per page Selector' }, "bInfo": true, "bFilter": false, // Disable searching "iDisplayLength": 10, // Ajax related settings "bServerSide": true, "sServerMethod": "POST", "bProcessing": true, "sAjaxSource": "http://api.gravycard.com/v1/promoter/emp/history.json", "fnServerData": function(sSource, aoData, fnCallback) { $.ajax({ "dataType": "json", "contentType": "application/json; charset=utf-8", "type": "POST", "url": sSource, "data": aoData, "success": fnCallback }); }, "aoColumns": [ {"sName": "Name", "mData": "empName"}, {"sName": "Title", "mData": "empTitle"}, {"sName": "Telephone", "mData": "empTelephone"}, {"sName": "Role", "mData": "empRole"}, {"sName": "Promotion(s)", "mData": "empNumPromos"} ] }); }());