为了账号安全,请及时绑定邮箱和手机立即绑定

新手问题:ajax与json如何从服务器上获取JSON数据?

新手问题:ajax与json如何从服务器上获取JSON数据?

Helenr 2018-09-11 14:10:39
我第一次写的AJAX与JSON方法,有点不懂怎么弄的呢,恳请各位老师帮忙说解,由于什么原因出错的?<!DOCTYPE html><html><head><script src="http://cdn.bootcss.com/jquery/1.11.1/jquery.min.js"></script><script>    $(function () {        $("button").click(function(){            $.ajax({                url:"http://www.tutorialspoint.com/json/data.json",                type:"POST",                dataType: "json",                success:function(data){                    $("#name").html(data.name);                    $("#country").html(data.country);                },                error: function (err) {                    console.log(err)                }            });        })    });</script><title>tutorialspoint.com JSON</title></head><body><h1>Cricketer Details</h1><table class="src"><tr><th>Name</th><th>Country</th></tr><tr><td><div id="name">Sachin</div></td><td><div id="country">India</div></td></tr></table><div class="central"><button type="button">Update Details </button></body></html>
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 562 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信