I'm trying to fetch json response from Instragram API with no result.
I use the code below which fetch data, but with error Uncaught SyntaxError: Unexpected token :
<script type="text/javascript">
$(document).ready(function(){
$.ajax({
type : "Get",
url :"https://api.instagram.com/v1/media/search?access_token=MYTOKEN&lat=00.0&lng=00.0&distance=30000?callback=?",
dataType :"jsonp",
jsonp: false,
jsonpCallback: " ",
success : function(instagramres){
alert(instagramres);
document.write(instagramres.meta.code);
},
error : function(httpReq,status,exception){
alert(status+" "+exception);
}
});
});
</script>
I have changed jsonp:false
to jsonp:true
with no result.
As I said in my comment, you don't need params such as type
(as by default it's get
) and jsonpCallback
(unless you want to have your own callback method). You may specify the callback thru the jsonp
param. Take a look at the code below and see if that works for you.
$(document).ready(function(){
$.ajax({
url: "https://api.instagram.com/v1/media/search?access_token=MYTOKEN&lat=00.0&lng=00.0&distance=30000",
// The name of the callback parameter
jsonp: "callback",
// Tell jQuery we're expecting JSONP
dataType: "jsonp",
// Deal with the response
success: function(instagramres){
alert(instagramres);
}
});
});