Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 使用$.getJSON()等待响应_Jquery_Json_Getjson - Fatal编程技术网

Jquery 使用$.getJSON()等待响应

Jquery 使用$.getJSON()等待响应,jquery,json,getjson,Jquery,Json,Getjson,我(试图)在PHP中使用JSON 我想使用此插件绘制一个图形: 问题是:它是在新数据到达之前绘制的。是否仍然需要让jQuery等待$.getJSON()并打印它 myArray和title是稍后将使用的新数据 $.getJSON('./ajax/refreshData.php', function(data) { myArray = data.arrayName; newTitle = data.newTitle; }); plot1 = $.jqplot('divname',

我(试图)在PHP中使用JSON

我想使用此插件绘制一个图形: 问题是:它是在新数据到达之前绘制的。是否仍然需要让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,

将plot1的赋值移动到为myArray赋值结果的回调中
$.getJSON('./ajax/refreshData.php', function(data) {
    myArray = data.arrayName;
    newTitle = data.newTitle;
    plot1 = $.jqplot('divname', [ myArray ], {
       series : [ {
       renderer : $.jqplot.BarRenderer} ],
       title : newTitle,
});