Solved

JavaScript XML request without callback?

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Jquery form 9 39
How to log java errors in tomcat 8 24
[form-control] Retain values after a POST action 21 32
Validating number not work with decimal 4 23
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This video teaches viewers about errors in exception handling.

756 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