How to Get JSON from External URL?

Disqus api help json ajax?

  • url = "http://disqus.com/api/get_forum_list?us… this url returns a json object. how will process this through ajax. is this the right way httpObject.open("GET", url, true);

  • Answer:

    try this (it's cross browser friendly)- //////////////////////////////////////… var xmlhttp=null; if(window.XMLHttpRequest){ xmlhttp=new XMLHttpRequest(); } else if(window.ActiveXObject){ xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } if(xmlhttp!=null){ xmlhttp.onreadystatechange=function(){ if(xmlhttp.readyState==4){ var JSON=xmlhttp.responseText; var obj=eval("("+JSON+")");// this turns the JSON into an object // now call a function and pass it "obj" // or just do something with it here }}} xmlhttp.open("GET",url,true); xmlhttp.send(null);

frank r at Yahoo! Answers Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.