Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

JSON AJAX call

Posted on 2007-10-21
2
Medium Priority
?
1,008 Views
Last Modified: 2008-01-09
I have a php page called example.php,
which consists of JSON like:
a = {'foo' : 5, 'bar' : 7}

what is the appropriate *synchronous* AJAX call to make in the space below:
var a;
...synchronous AJAX...
print(a.blah);
0
Comment
Question by:xomn
2 Comments
 
LVL 3

Accepted Solution

by:
aidinet earned 2000 total points
ID: 20117608
objXMLHttp = getXmlHttpObject();
objXMLHttp.onreadystatechange = evalRespons;
objXMLHttp.open("GET","example.php",false);
objXMLHttp.send(null);

function evalRespons(){
      if(objXMLHttp.readyState==4 ){
            eval(objXMLHttp.responseText)
      }
}

function getXmlHttpObject(){
      var objXMLHttp=null;
      if (window.XMLHttpRequest){
            objXMLHttp=new XMLHttpRequest();
      }else if (window.ActiveXObject){
            objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
      return objXMLHttp;
}
0
 
LVL 82

Expert Comment

by:hielo
ID: 20119045
Beware: the "POST" or "GET" parameters are case sensitive. Here is an excellent resource.
http://www.xul.fr/en-xml-ajax.html
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Australian government abolished Visa 457 earlier this April and this article describes how this decision might affect Australian IT scene and IT experts.
While opting for any web-to-print solution, you need to discuss with your team and some of your end users and know their opinions about your decisions. In this article we list down some questions you need to ask yourself.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Learn how to set-up PayPal payment integration in your Wufoo form. Allow your users to remit payment through PayPal upon completion of your online form. This is helpful for collecting membership payments, customer payments, donations, and more.
Suggested Courses
Course of the Month13 days, 13 hours left to enroll

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question