0
我想將數組的內容傳遞給jplot函數,但是我得到了沒有數據。 該數組在php中是json encoden,它是一個關聯數組。jqplot傳遞數組未捕獲的異常:沒有數據
$.ajax({
type: "POST",
url: "actions/myphp.php",
data: PassArray,
dataType: 'json',
beforeSend: function (html) { // this happens before actual call
// alert(html);
},
success: function (html) { // this happens after we get results
// $("#loginoutcome").text(html);
// alert(html);
var obj =html ;
// Now the two will work
$.each(obj, function(key, value) {
alert(key + ' ' + value);
});
var s1 = obj;
var plot8 = $.jqplot('pie8', [s1], {
grid: {
drawBorder: false,
drawGridlines: false,
background: '#ffffff',
shadow: false
},
axesDefaults: {},
seriesDefaults: {
renderer: $.jqplot.PieRenderer,
rendererOptions: {
showDataLabels: true
}
},
legend: {
show: true,
rendererOptions: {
numberRows: 1
},
location: 's'
}
});
我也嘗試過使用var s1 = [obj];
但沒有也行通...
任何錯誤的工作?你可以看看Firebug中的ajax調用嗎? POST的結果是什麼? – Owlvark 2013-03-10 22:52:06
請讓我們看看s1的內容。您可以在Ajax調用後使用console.log(s1) – AnthonyLeGovic 2013-03-11 07:29:55