Skip to content Skip to sidebar Skip to footer

Jquery Syntax Error For A Valid Json

I am trying to get the instagram user details using jQuery ajax which can be found from the url https://www.instagram.com/instagram/?__a=1 But when i call the same through ajax fr

Solution 1:

If you are getting respone as JSON, Change from dataType: "jsonp" to dataType: "json"

Valide json response would look like

{"Name":"Foo","Id":192.168.73.96,"Rank":7}

And jsonp would be like

parseResponse({"Name": "Foo", "Id": 1234, "Rank": 7});

Get more details form here

Solution 2:

Instagram does not support jsonp, it is not used much anymore in favor of CORS. Change jsonp to json. However, this will not work because Instagram's CORS policy prevents it. You will need to use the API provided by Instagram.

$(document).ready(function() {
  var instagram = 'instagram';
  $.ajax({
    url: 'https://www.instagram.com/' + instagram + '/?__a=1',
    dataType: "json",
    success: function(e) {
      document.write(JSON.stringify(e));
    }
  });
});
<scriptsrc="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

Post a Comment for "Jquery Syntax Error For A Valid Json"