2010-08-10 96 views
1

響應我(試圖)使用JSON與PHP。

我想使用這個插件繪製一個圖表:http://www.jqplot.com 問題是:這是新的數據到達之前的情節。無論如何,讓jQuery等待$ .getJSON()和它的陰謀嗎?

myArraytitle是將在稍後使用的新數據。

$.getJSON('./ajax/refreshData.php', function(data) { 
    myArray = data.arrayName; 
    newTitle = data.newTitle; 
}); 

plot1 = $.jqplot('divname', [ myArray ], { 
    series : [ { 
    renderer : $.jqplot.BarRenderer} ], 
    title : newTitle, 

...

+1

舉措,其中myarray的分配結果plot1的分配步入回調 – 2010-08-10 04:16:28

回答

3
$.getJSON('./ajax/refreshData.php', function(data) { 
    myArray = data.arrayName; 
    newTitle = data.newTitle; 
    plot1 = $.jqplot('divname', [ myArray ], { 
     series : [ { 
     renderer : $.jqplot.BarRenderer} ], 
     title : newTitle, 
});