RESTFul Client入门实例

client.html文件内容为:

<!DOCTYPE html>
<html>
<head>
    <title>RESTFul Client test page</title>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
</head>
<body>
<script src="./jquery-2.1.3.min.js"></script>
<script src="./testRestfulClient.js"></script>

<script>
document.write("<h1>Send Restful Get and Post:</h1>");
</script>
<div>
    <input id="sendRestfulGet" onclick="sendRestfulGet();" type="button" value="SendGet">
    </br>
</div>
</body>
</html>

testRestfulClient.js文件内容为:

function sendRestfulGet(){
    var doubanURL = 'https://api.douban.com//v2/movie/top250';
    $.ajax({
        url: doubanURL,
        type: 'Get',
        data: '',
        dataType: 'JSONP',
        crossDomain: true,
        success: function(data){
            console.log(data);
        }
    });
}

猜你喜欢

转载自www.cnblogs.com/ratels/p/10279556.html