javascript - 新手求问ajax 获取数据
仅有的幸福
仅有的幸福 2017-06-06 09:53:48
0
1
456

下载phpstudy搭建本地服务器

data.json如下

{
    name:"lvyuanyaun",
    age:"25"
}

hello.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>demo</title>
</head>
<body>
     <button id="btn">点击</button>
    <h5 id="text">....</h5>
    <script src="jq.js"></script>
    <script type="text/javascript">
        $("#btn").click(function() {
        $.ajax({
        type: "GET",
        url: "data.json",
        dataType: "json",
        success:function(data) {
           console.log(data)
        }
      });

   })
    </script>
</body>
</html>

network显示data.json已被加载

console.log(data)什么都没显示

仅有的幸福
仅有的幸福

全部回复(1)
迷茫

把url那个参数那里改成带http的访问地址试试

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板