View Full Version : Basic Ajax Routine Help

02-19-2007, 10:22 PM
1) Script Title: Basic Ajax Routine

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/ajaxroutine.htm

3) Describe problem: Need to modify processGetPost function to return the results of the post, but can't get it working.

When the function is executed, I want it to return the results to the calling function, so I've modified it as follows:

function processGetPost(){
var myajax=ajaxpack.ajaxobj
var myfiletype=ajaxpack.filetype
if (myajax.readyState == 4){ //if request of file completed
if (myajax.status==200 || window.location.href.indexOf("http")==-1){ //if request was successful or running script locally
if (myfiletype=="txt")
// myresponse = myajax.responseText;
alert("Couldn't get file.");

And then in another function I call that function like this:

var myContent = ajaxpack.getAjaxRequest("getHelpContent.asp", "NavID=" + nav_id, processGetPost, "txt");

The alert aways returns "undefined", though, and I just can't figure out what I'm doing wrong (something painfully simple, I'm sure).

Could somebody please shed some light on this?

Thanks in advance!