我正在(尝试)将 JSON 与 PHP 结合使用。
我想使用这个插件绘制图表:http://www.jqplot.com 问题是:它正在新数据到达之前绘制。有没有办法让 jQuery 等待 $.getJSON() 并绘制它?
myArray
和 title
是稍后将使用的新数据。
$.getJSON('./ajax/refreshData.php', function(data) {
myArray = data.arrayName;
newTitle = data.newTitle;
});
plot1 = $.jqplot('divname', [ myArray ], {
series : [ {
renderer : $.jqplot.BarRenderer} ],
title : newTitle,
...
最佳答案
$.getJSON('./ajax/refreshData.php', function(data) {
myArray = data.arrayName;
newTitle = data.newTitle;
plot1 = $.jqplot('divname', [ myArray ], {
series : [ {
renderer : $.jqplot.BarRenderer} ],
title : newTitle,
});
关于jquery - 等待 $.getJSON() 响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3445962/