Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Remote call returning undefined

Status
Not open for further replies.

travisbrown

Technical User
Dec 31, 2001
1,016

I'm trying to return a remote call to an alert. Does the code below look correct? I'm getting 'undefined'.

Code:
function createRequestObject() {
	var ro;
	var browser = navigator.appName;
	if(browser == "Microsoft Internet Explorer"){
		ro = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		ro = new XMLHttpRequest();
	}
	return ro;
}

function getString(page) {
    var http = createRequestObject();
    http.open( 'get', page , true);
    http.onreadystatechange = function(){
         if ( http.readyState == 4 ) {
        var response = http.responseText;
        return response;
        http = null;
        }    
    };
    http.send(null);
}

alert(getString('mypage.asp'));

The remote page is returning a string value when I run it in isolation.
 
I couldn't be certain about this, but try:

Code:
http.onreadystatechange = function([!]callBackData[/!]){
         if ( http.readyState == 4 ) {
        var response = [!]callBackData[/!].responseText;
        return response;
        http = null;
        }    
    };

Failing that, try asking in forum1600.

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top