Solved

JavaScript XML request without callback?

Posted on 2009-06-29
3
486 Views
Last Modified: 2013-11-23
Hi there,

Are there any JavaScript XML libraries out there that let us make XML calls without requiring a callback?
Why? Because we are trying to rapidly develop an application and with all the callbacks, things are really looking messy in the code.

0
Comment
Question by:the_cyman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 9

Assisted Solution

by:jmanGJHS97
jmanGJHS97 earned 450 total points
ID: 24739627
Any asynchronous interactions with server components require callbacks.  Maybe instead you could restructure the callbacks to be more efficient, but you can't simply avoid them.
0
 
LVL 7

Expert Comment

by:Xxavier
ID: 24741356
XML calls are call backs, to get data from server you have to call back, period :(
0
 

Accepted Solution

by:
the_cyman earned 0 total points
ID: 24817673
It is possible:
function GetSynchronousJSONResponse(url, postData) {
    var xmlhttp = null;
    if (window.XMLHttpRequest)
        xmlhttp = new XMLHttpRequest();
    else if (window.ActiveXObject) {
        if (new ActiveXObject("Microsoft.XMLHTTP"))
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        else
            xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    }
        // to be ensure non-cached version of response
    url = url + "?rnd=" + Math.random();
   
    xmlhttp.open("POST", url, false);//false means synchronous
    xmlhttp.send(postData);
    var responseText = xmlhttp.responseText;
    return responseText;
}
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses

636 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