V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
v2sbzd
V2EX  ›  程序员

js 或者 jquery 怎么正确请求到这个 Get 接口的数据 http://api.16820.com/newxiaoxi/fns/id/3 ???求晒代码!

  •  
  •   v2sbzd · 2018-07-23 16:47:52 +08:00 · 1566 次点击
    这是一个创建于 2096 天前的主题,其中的信息可能已经有所发展或是发生改变。
    2 条回复    2018-07-25 14:36:40 +08:00
    jqin4
        1
    jqin4  
       2018-07-23 17:39:57 +08:00
    fetch("http://api.16820.com/newxiaoxi/fns/id/3 ")
    .then((reponse)=>reponse.json()) //这里是一个 promise 对象
    .then((json)=>console.log(json)) // extract json


    我也是小白, 试一下。fetch 会 return 一个 promise 对象
    suduo1987
        2
    suduo1987  
       2018-07-25 14:36:40 +08:00
    ```javascript
    $.ajax({
    url:'http://api.16820.com/newxiaoxi/fns/id/3',
    type:'get',
    success:function(data){
    // to do ...
    }
    });
    ```
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5581 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 02:52 · PVG 10:52 · LAX 19:52 · JFK 22:52
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.