Using $.getJSON() to visit cross domain resources.

This commit is contained in:
vinjn
2014-05-17 23:34:40 +08:00
parent 0f88f81beb
commit 338da6c0d5

View File

@@ -20,14 +20,10 @@ body, html,#allmap {width: 100%;height: 100%;overflow: hidden;margin:0;}
var map = new BMap.Map("allmap"); // 创建Map实例
map.centerAndZoom("上海",15); // 初始化地图,设置中心点坐标和地图级别。
$.ajax({
url: "http://api.douban.com/event/location/shanghai?type=exhibition&max-results=50",
})
.done(function( response ){
console.log("received", response);
})
.fail(function() {
alert("无法访问豆瓣同城API");
});
// https://github.com/unixcrh/DOUBANTONGCHENG/blob/master/DouBanTongCheng/ContentVC.m
$.getJSON("https://api.douban.com/v2/event/list?loc=shanghai&type=exhibition&max-results=50&callback=?", function(result){
//response data are now in the result variable
console.log(result);
});
</script>