cross domain jquery get
You can't use $.get
because that does an ajax call, which will be cross-origin and thus blocked by the Same Origin Policy, and the Twitter API you're trying to access doesn't support Cross-Origin Resource Sharing (or if it does, it doesn't allow either origin null
or http://jsbin.com
, which is the one I tried).
The API does support JSONP (which is not a true ajax call), though, so just changing the $.get
to an $.ajax
specifying JSONP
works:
$.ajax({ url: url, dataType: "jsonp", success: function (data) { console.log(data) alert(data); }});