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
Solved

JavaScript XML request without callback?

Posted on 2009-06-29
3
482 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
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
hashmap order 17 36
Explain this javascript function to me 2 25
HTML Anchor Link Problem 3 35
Only allow one check box 17 24
Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will learn how to implement Singleton Design Pattern in Java.

809 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