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 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘