在document.ready上加载ajax调用时,我遇到了问题,但是当我合并一个窗口时。滚动函数ajax调用成功地呈现了关于如何调整代码的任何建议。我不能为这个小提琴提供一个小提琴,因为我不知道如何在小提琴中包含任何图表,这里是我代码的一个片段:
function DataStreamer(){
$.ajax({ // then make an AJAX-request
async: false,
cache: false,
url: '/APAC/TW/Resources/js/gethistoricalpricing.js',
dataType: 'json', // csv data is text
success: function(resp) { // "resp" variable is a response to AJAX-request
// Append new data into the 'ds1' data set
var line = [], json = resp, i= 0;
for (i; i < resp.length; i++) {
rawDate = json[i]['Date'].split('/');
hisDate = rawDate[2] + rawDate[0] + rawDate[1];
hisPrice = json[i]['Price'];
line.push("\n"+hisDate + "," + hisPrice);
}
chart.appendData('ds_prices', line);
// getSeriesById method returns 's1' series 'main' chart,
// you can also use full path to the series through the objectModel, but this way is shorter
chart.commitDataChanges();
}
})
}
$(document).ready(function(){
DataStreamer();
});发布于 2013-10-30 10:33:55
我已经注意到了我的函数的问题,并通过让ajax调用位于图表所在的相同级别上解决了这个问题,上一次是图表在没有等待数据的情况下被呈现。让图表空着。所以,滚动函数工作的原因可能是因为当滚动到页面的特定部分时,它会强制ajax数据调用。
发布于 2013-10-30 08:52:13
在一开始,如果没有async: false,这将是完全可行的。为什么要使用AJAX调用而不是异步调用?
https://stackoverflow.com/questions/19677606
复制相似问题