Ajax 请求

ajax 请求解析josn

其实代码很简单,主要是怎么模拟测试数据,例如在GitHub page上建个data.json我们请求

https://naiop.github.io/test/data.json
复制代码
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>Ajax请求</title>
    </head>
    <body>
      <h2>打开控制台查看详情</h2>
    </body>
    <script src="https://common.cnblogs.com/scripts/jquery-2.2.0.min.js"></script>
    <script>
    $(function(){
        console.log("Ajax");    
         $.ajax({
            type: "GET",
            url: "https://naiop.github.io/test/data.json",                      
            dataType: "json",
            success: function (res) {
                
               console.log(res);               
            },
            error: function (err) {
               console.log(err);
            }
        });        
    });
    </script>
</html>
复制代码

 

本文作者:浅绿色i

本文链接:https://www.cnblogs.com/xfweb/p/15218279.html

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   浅绿色i  阅读(39)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示
💬
评论
📌
收藏
💗
关注
👍
推荐
🚀
回顶
收起