eb0c6551
V2EX  ›  问与答

Javasript,getJSON 出现 Uncaught TypeError: Cannot read property 'length' of undefined 错误

  •  
  •   eb0c6551 · Jun 10, 2014 · 9812 views
    This topic created in 4382 days ago, the information mentioned may be changed or developed.
    我在使用ECharts绘制K线图,直接上代码

    https://gist.github.com/892645e65044dc8bd6a2

    失败时的console输出

    http://imgur.com/8kfBkVb

    可以看出来我应该成功传递了呀,非常困惑。。。

    感谢!
    Supplement 1  ·  Jun 11, 2014
    感谢@binux @sneezry,我明白了,已解决,结贴。
    7 replies    2014-06-11 00:16:35 +08:00
    eb0c6551
        1
    eb0c6551  
    OP
       Jun 10, 2014
    不知道为什么贴代码和贴图都失败了..

    再次尝试

    https://gist.github.com/892645e65044dc8bd6a2

    binux
        2
    binux  
       Jun 10, 2014   ❤️ 1
    $.getJSON 是异步的,异步你懂吗?
    eb0c6551
        3
    eb0c6551  
    OP
       Jun 10, 2014
    @binux 抱歉我不懂。。。对于Web端零基础,请问我需要怎么做?
    binux
        4
    binux  
       Jun 10, 2014   ❤️ 1
    @eb0c6551 去学
    eb0c6551
        5
    eb0c6551  
    OP
       Jun 10, 2014
    @binux 继续求教,我这样的思路不对吗?我觉得我的方法很简单直接呐。
    binux
        6
    binux  
       Jun 10, 2014   ❤️ 1
    @eb0c6551 异步 callback 回调返回的时候不是你想的那样,返回的地方也不是你调用的地方。如果你要继续写 js,就去学。
    sneezry
        7
    sneezry  
       Jun 11, 2014 via iPhone   ❤️ 1
    回调函数不能用return返回结果哒,异步不会阻塞后面的代码。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3591 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 04:50 · PVG 12:50 · LAX 21:50 · JFK 00:50
    ♥ Do have faith in what you're doing.