微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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>

 

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐