jsonp 示例

1. 从url拿json

2.处理response的json



<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<title>jsonp sample</title>
</head>
<body>
<div id="gists">
</div>
<script>
$(document).ready(function(){
                $.getJSON('https://api.github.com/gists?callback=?', function(response){
                    $.each(response.data, function(i, gist){
                        $('#gists').append('<li>' + gist.comments_url);
                    });
                });
            });</script>
</body>
</html>


你可能感兴趣的:(jsonp 示例)