我做了一些javascript来从api获取对象。现在错误显示我没有访问控制?我该怎么办?
<script type="text/javascript">
function getLatest(){
var data = {};
$.ajax({
url: 'http://api.rappler.com/index.php?option=com_rappler&task=mobileapi.getarticlelist&limit=5&catid=23',
data: data
});
console.log(data);
}
</script>
答案 0 :(得分:0)
Try this one:
<script type="text/javascript">
function getLatest(){
var data = {};
$.ajax({
url: 'http://api.rappler.com/index.php?option=com_rappler&task=mobileapi.getarticlelist&limit=5&catid=23',
data: data,
async:true,
dataType : 'jsonp', //you may use jsonp for cross origin request
crossDomain:true
});
console.log(data);
}
getLatest();
</script>