问题
Hello i try get this json with $.getJSON, also $.ajax(...) but nothing...
jQuery.ajax({
url: "http://imgur.com/gallery/hot/page/1.json",
type: 'GET',
crossDomain:true,
success: succ
});
always i have errors like XMLHttpRequest cannot load http://imgur.com/gallery/hot/page/1.json. Origin my_ip is not allowed by Access-Control-Allow-Origin.
also i tried get jsonp request but also nothing..
jQuery.ajax({
url: "http://imgur.com/gallery/hot/page/1.json",
type: 'GET',
dataType: 'jsonp',
crossDomain:true,
success: succ
});
have enother error Uncaught SyntaxError: Unexpected token :
its looks like it is possible get this json with this plugin jquery.xdomainajax.js
回答1:
Here is my solution, maybe someone it will be usefull.
<script src="jquery.xdomainajax.js"></script>
<script>
$(document).ready(function() {
jQuery.ajax({
url: "http://imgur.com/gallery/hot/page/1.json",
type: 'GET',
success: function(data){
//creating json object
var jsonResp=$.parseJSON($(data.responseText).text().trim());
}
});
});
</script>
来源:https://stackoverflow.com/questions/8014504/get-http-imgur-com-gallery-hot-page-1-json-with-jquery