• 请不要在回答技术问题时复制粘贴 AI 生成的内容
v2sbzd
V2EX  ›  程序员

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

  •  
  •   v2sbzd · Jul 23, 2018 · 2227 views
    This topic created in 2894 days ago, the information mentioned may be changed or developed.
    2 replies    2018-07-25 14:36:40 +08:00
    jqin4
        1
    jqin4  
       Jul 23, 2018
    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  
       Jul 25, 2018
    ```javascript
    $.ajax({
    url:'http://api.16820.com/newxiaoxi/fns/id/3',
    type:'get',
    success:function(data){
    // to do ...
    }
    });
    ```
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3767 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 00:49 · PVG 08:49 · LAX 17:49 · JFK 20:49
    ♥ Do have faith in what you're doing.