Problem passing json into jquery graph(flot) -


i trying retrieve json pass flot graph. know json right because hard coded check, i'm pretty sure i'm not passing right because it's not showing up. here's javascript:

var total = $.ajax({   type: "post",   async: false,   url: "../api/?key=xxx&api=report&crud=return_months&format=json" }).responsetext; //var total = $.evaljson(total); var plot = $.plot($("#placeholder"),total); 

here's json:

[ { data: [[1,12], [2,43], [3,10], [4,17], ], label: "e-file"}, { data: [[1,25], [2,35], [3,3], [4,5], ], label: "bank products" }, { data: [[1,41], [2,87], [3,30], [4,29], ], label: "all returns" } ], {series: {lines: { show: true },points: { show: true }}, grid: { hoverable: true, clickable: true }, yaxis: { min: 0, max: 100 }, xaxis: { ticks: [[1,"january"],[2,"february"],[3,"march"],[4,"april"],[5,"may"],[6,"june"],[7,"july"],[8,"august"],[9,"september"],[10,"october"],[11,"november"],[12,"december"]] }} 

make sure set datatype: "json" option well. aside, in success callback function without locking ui while waiting response, this:

$.ajax({   type: "post",   datatype: "json",    url: "../api/?key=xxx&api=report&crud=return_months&format=json",   success: function(total) {     var plot = $.plot($("#placeholder"),total);     //do more work if needed   } }); 

alternatively, use $.post() same in shorter form, this:

$.post("../api/?key=xxx&api=report&crud=return_months&format=json",    function(total) {     var plot = $.plot($("#placeholder"),total);     //do work   }, "json"); 

Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -