returning the XML result to a returning function

Posted on 2008-11-18
Last Modified: 2014-10-18
When I call compexists and alert the response text it displays it correctly, however it displays "undefined" in the validate_transfer function.  I'm not sure what I'm doing wrong here.  I'm using IE 7
function validate_transfer(formname,dialid)


	var dupname = compexists(,dialid);



function compexists(compname,dial_id)


    var xmlHttp = getXMLHttp();

    xmlHttp.onreadystatechange = function()


         if(xmlHttp.readyState == 4)



                 return xmlHttp.responseText;				


      }"GET", "compexists.php?compname="+compname+"&dialplan_id="+dial_id, true); 



Open in new window

Question by:ddsexperts
    LVL 3

    Expert Comment

    The function compexists doesn't actually return anything. The function onreadystatechange does, see the difference? You'll have to change the onreadystatechange function to actually call part 2 of your validate_transfer();

    You'll do something similar to:

    validate_transfer(formname, dialid);

    change the readystatechange function to

     if(xmlHttp.readyState == 4)

    then do whatever you want in part 2 with the response.
    LVL 2

    Accepted Solution

    Ajax call is asynchronous, so it goes into background and control gets transferred to the alert() which shows undefined because it does not contains any data.

    Featured Post

    Live: Real-Time Solutions, Start Here

    Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    WCF Rest Service Timeout Exception 3 92
    WEB Service vs ??? 7 83
    CSS Question.. 3 64
    Can't play streaming video on 7 94
    Introduction HyperText Transfer Protocol ( or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
    New Relic recently released its Synthetics product that allows for the creation of performance monitors that periodically test a site's performance. If you wish to test an interactive workflow New Relic employs Selenium WebDriverJS to run those test…
    This video teaches viewers how to create their own website using cPanel and Wordpress. Tutorial walks users through how to set up their own domain name from tools like Domain Registrar, Hosting Account, and Wordpress. More specifically, the order in…
    Learn how to set-up custom confirmation messages to users who complete your Wufoo form. Include inputs from fields in your form, webpage redirects, and more with Wufoo’s confirmation options.

    745 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

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now