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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"Classic" ASP with AJAX 1

Status
Not open for further replies.

AndyInNC

Programmer
Sep 22, 2008
76
US
If I have a ASP page with multiple functions in it and I want to call one via AJAX, can I do that? Or do I have to have a separate ASP for the call?

E.g.
My javascript looks roughly like
Code:
function getAjaxResults()
{
    var oXmlHTTP = getXmlHttpObject();
    
    var sURL = "Search.asp?srch=a32";
    
    oXmlHTTP.onreadystatechange = function AjaxFunc()
                {
                   var sTemp = oXmlHTTP.responseText;
                   document.getElementById("div1").innerHTML = sTemp;
                }
}

Can the Search.asp have multiple funcs in it and I just call one of those funcs?

Thanks in advance
 
your search.asp file can do whatever you want it to do - if you want to execute a specific function, pass it in the querystring:

var sURL = "Search.asp?srch=a32&execFunc=functionOne";

var sURL = "Search.asp?srch=a32&execFunc=functionTwo";

var sURL = "Search.asp?srch=a32&execFunc=functionThree";

in your asp page

Code:
<%
strFTE = request.querystring("execFunc")
select case strFTE
case "functionOne"

case "functionTwo"

case "functionThree"

end select
%>



TIP: trying googling the answer before posting, you'll find that more times than not someone else somewhere has had the same request and posted an answer online.
----
I have recently been semi-converted to ensuring all my code (well most of it) works in both javascript and non-javascript enabled browsers
 
Well that was simple. (I didn't even think of that one.)

So I'll still need a dedicated ASP page in order to read the queryString to call a func or sub, but from the JavaScript I can't specify a given procedure that already lives in a generic library of code.

Not what I was hoping to hear, but definitely better than what I've got. Thx vic.
 
So I'll still need a dedicated ASP page in order to read the queryString to call a func or sub, but from the JavaScript I can't specify a given procedure that already lives in a generic library of code.

Only if that function is written in JS and referenced from the file.


TIP: trying googling the answer before posting, you'll find that more times than not someone else somewhere has had the same request and posted an answer online.
----
I have recently been semi-converted to ensuring all my code (well most of it) works in both javascript and non-javascript enabled browsers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top