V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
chen

V2EX JSON 调用问题

  •  
  •   chen · Feb 21, 2011 · 8374 views
    This topic created in 5543 days ago, the information mentioned may be changed or developed.
    @livid 使用 jQuery 调用不成功,求助一下哪里出错了

    10 replies    1970-01-01 08:00:00 +08:00
    chen
        1
    chen  
    OP
       Feb 21, 2011
    https://gist.github.com/836889

    gist 怎么不出来呢?
    chen
        2
    chen  
    OP
       Feb 21, 2011
    原来 http 才能出来。。。
    darasion
        3
    darasion  
       Feb 21, 2011
    我觉得应该不是你的问题。
    查看了一下,这个返回的 json 里边一些特殊字符没有经过处理哦。
    比如bio里边的回车换行都没有经过转义。

    cc @livid
    chone
        4
    chone  
       Feb 21, 2011
    ajxa不能跨域访问,可以在本地做一个代理转接
    chone
        5
    chone  
       Feb 21, 2011
    @darasion 格式确实也有问题
    chen
        6
    chen  
    OP
       Feb 21, 2011
    @chone 可是这个怎么就没有问题呢?

    http://gist.github.com/836907
    chone
        7
    chone  
       Feb 21, 2011
    @chen 这个用的是JSONP,需要服务器支持的。
    kingwkb
        8
    kingwkb  
       Feb 21, 2011
    你要加callback=?
    darasion
        9
    darasion  
       Feb 21, 2011
    @chen 嗯嗯。有 callback参数的一般都是 jsonp,jsonp 可以跨域访问,jQuery默认支持这种形式。

    这个参数名字不一定非叫callback,也可以是别的,这个参数主要定义一个js函数名字,把返回的jsonp用<script src="xxxxx.js"></script>引入,然后在别的地方调用callback里这个函数,就能跨域了。

    具体细节可以google一下。
    chen
        10
    chen  
    OP
       Feb 21, 2011
    @chone @darasion thanks all!
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   872 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 39ms · UTC 22:01 · PVG 06:01 · LAX 15:01 · JFK 18:01
    ♥ Do have faith in what you're doing.