jquery - How to use json data for Flot in DataTables -


i trying draw barchart , show data chart in table below. using flot , datatables. want use json output in both.

this have:

        $.ajax({              type: "post",             url: '/index.php',             datatype: 'json',             success: function(r) {                  $.plot($("#placeholder"), [r], {                     series: {                         bars: {                             show: true                         }                     }                 });                   $('#example').datatable( {                     "ajax": r                 } );              },             error: function(err) {                  alert("oops");                 return false;              }          });  

the chart draws fine datatables gives following error:

datatables warning: table id=example - invalid json response. more information error, please see http://datatables.net/tn/1 

however, have checked json , valid , flot uses fine. json is:

{"data":[[0,1267],[1,1485],[2,1516],[3,1418],[4,1308],[5,1307],[6,1392]]} 

this leads me conclude either json format incorrect datatables or jquery wrong. can guide me?

try this:

$('#example').datatable( {                     data: r.data                 } ); 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -