1) Script Title: Basic Ajax Routine
2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...jaxroutine.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:
And then in another function I call that function like this:Code: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; return(myajax.responseText); else return(myajax.responseXML); } else alert("Couldn't get file."); } }
The alert aways returns "undefined", though, and I just can't figure out what I'm doing wrong (something painfully simple, I'm sure).Code:var myContent = ajaxpack.getAjaxRequest("getHelpContent.asp", "NavID=" + nav_id, processGetPost, "txt"); alert(myContent);
Could somebody please shed some light on this?
Thanks in advance!
--Jon



Reply With Quote
Bookmarks