weixin_33698823 2013-10-30 08:49 采纳率: 0%
浏览 30

Ajax调用文档准备好了

Im having problems with my ajax call loading on document.ready but when I incorporate a window. scroll function the ajax call is successfully rendered any suggestions on how I can tweak my code. I can't provide a fiddle for this one because I don't no how to include anychart in the fiddle here is a snippet of my code:

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("
"+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();

});
  • 写回答

2条回答 默认 最新

  • weixin_33725515 2013-10-30 08:52
    关注

    This would be fully working without async: false at the beginning. Why would you want to have an AJAX call not async?

    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?