等待与$ .getJSON()
问题描述:
响应我(试图)使用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,
});
举措,其中myarray的分配结果plot1的分配步入回调 – 2010-08-10 04:16:28