469,946 Members | 1,785 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,946 developers. It's quick & easy.

Need Ajax Help: Targeting Specific Methods

Hi.

I have an ajax question.
I am wondering if it is possible to get the response from a method
within a given page, and that function alone? Traditionally, I have
been getting the response from the Page_Load method of the targeted
page, but now I want the response from a particular method on the
target page:

Public Sub SomeCallback(ByVal sender As Object, ByVal e As EventArgs)

'RETURN XML FOR CALLBACK

End Sub

Could somebody tell me how to focus on the resonse of a given method
inside a page? Thanks.

Mar 12 '07 #1
4 1205
On Mar 12, 9:55 am, "pbd22" <dush...@gmail.comwrote:
Hi.

I have an ajax question.
I am wondering if it is possible to get the response from a method
within a given page, and that function alone? Traditionally, I have
been getting the response from the Page_Load method of the targeted
page, but now I want the response from a particular method on the
target page:

Public Sub SomeCallback(ByVal sender As Object, ByVal e As EventArgs)

'RETURN XML FOR CALLBACK

End Sub

Could somebody tell me how to focus on the resonse of a given method
inside a page? Thanks.
Events are fired by DOM elements (e.g. load event when the document
has finished loading), javscript functions don't have any such
concept.

If you want something to happen when a function is called, either have
the function call the method or wrap the function in some other method
and call your "event" function straight after the one you want to
watch.
--
Rob

Mar 12 '07 #2
On Mar 11, 9:13 pm, "RobG" <r...@iinet.net.auwrote:
On Mar 12, 9:55 am, "pbd22" <dush...@gmail.comwrote:
Hi.
I have an ajax question.
I am wondering if it is possible to get the response from a method
within a given page, and that function alone? Traditionally, I have
been getting the response from the Page_Load method of the targeted
page, but now I want the response from a particular method on the
target page:
Public Sub SomeCallback(ByVal sender As Object, ByVal e As EventArgs)
'RETURN XML FOR CALLBACK
End Sub
Could somebody tell me how to focus on the resonse of a given method
inside a page? Thanks.

Events are fired by DOM elements (e.g. load event when the document
has finished loading), javscript functions don't have any such
concept.

If you want something to happen when a function is called, either have
the function call the method or wrap the function in some other method
and call your "event" function straight after the one you want to
watch.

--
Rob

Thanks.

Maybe I misunderstand what you are saying, but, I still don't
understand how to call a server method from the client-side
ajax call. would you mind showing me how to solve this problem? For
example, for the below ajax call, I am getting the response from the
Server.aspx pages's Page_Load method. But, how would I design the
below function to get the response from the server's SomeCallback
method?

function startRequest() {
if (window.XMLHttpRequest) {
req = new XMLHttpRequest();
} else if (window.ActiveXObject) {
isIE = true;
req = new ActiveXObject("Microsoft.XMLHTTP");
}
req.open("GET", "server.aspx", true);
}

Mar 12 '07 #3
On Mar 12, 5:18 pm, "pbd22" <dush...@gmail.comwrote:
On Mar 11, 9:13 pm, "RobG" <r...@iinet.net.auwrote:
On Mar 12, 9:55 am, "pbd22" <dush...@gmail.comwrote:
Hi.
I have an ajax question.
I am wondering if it is possible to get the response from a method
within a given page, and that function alone? Traditionally, I have
been getting the response from the Page_Load method of the targeted
page, but now I want the response from a particular method on the
target page:
Public Sub SomeCallback(ByVal sender As Object, ByVal e As EventArgs)
'RETURN XML FOR CALLBACK
End Sub
Could somebody tell me how to focus on the resonse of a given method
inside a page? Thanks.
Events are fired by DOM elements (e.g. load event when the document
has finished loading), javscript functions don't have any such
concept.
If you want something to happen when a function is called, either have
the function call the method or wrap the function in some other method
and call your "event" function straight after the one you want to
watch.
--
Rob

Thanks.

Maybe I misunderstand what you are saying, but, I still don't
understand how to call a server method from the client-side
ajax call. would you mind showing me how to solve this problem? For
example, for the below ajax call, I am getting the response from the
Server.aspx pages's Page_Load method. But, how would I design the
below function to get the response from the server's SomeCallback
method?

function startRequest() {
if (window.XMLHttpRequest) {
req = new XMLHttpRequest();
} else if (window.ActiveXObject) {
isIE = true;
req = new ActiveXObject("Microsoft.XMLHTTP");
}
req.open("GET", "server.aspx", true);

}
Provide the script with a url parameter inside your ajax request, and
the script should call the proper method depending on this parameter.
You can't interfere with the work of your server script from inside
JavaScript. To ajax, i.e. to http protocol, all you're requesting is
the result of a program. What that program does is irrelevant for it,
as long as it gets the proper result. However, you can provide it with
parameters based upon which the server script can decide what methods
it's going to call.

Mar 12 '07 #4
On Mar 12, 10:36 am, "Darko" <darko.maksimo...@gmail.comwrote:
On Mar 12, 5:18 pm, "pbd22" <dush...@gmail.comwrote:
On Mar 11, 9:13 pm, "RobG" <r...@iinet.net.auwrote:
On Mar 12, 9:55 am, "pbd22" <dush...@gmail.comwrote:
Hi.
I have an ajax question.
I am wondering if it is possible to get the response from a method
within a given page, and that function alone? Traditionally, I have
been getting the response from the Page_Load method of the targeted
page, but now I want the response from a particular method on the
target page:
Public Sub SomeCallback(ByVal sender As Object, ByVal e As EventArgs)
'RETURN XML FOR CALLBACK
End Sub
Could somebody tell me how to focus on the resonse of a given method
inside a page? Thanks.
Events are fired by DOM elements (e.g. load event when the document
has finished loading), javscript functions don't have any such
concept.
If you want something to happen when a function is called, either have
the function call the method or wrap the function in some other method
and call your "event" function straight after the one you want to
watch.
--
Rob
Thanks.
Maybe I misunderstand what you are saying, but, I still don't
understand how to call a server method from the client-side
ajax call. would you mind showing me how to solve this problem? For
example, for the below ajax call, I am getting the response from the
Server.aspx pages's Page_Load method. But, how would I design the
below function to get the response from the server's SomeCallback
method?
function startRequest() {
if (window.XMLHttpRequest) {
req = new XMLHttpRequest();
} else if (window.ActiveXObject) {
isIE = true;
req = new ActiveXObject("Microsoft.XMLHTTP");
}
req.open("GET", "server.aspx", true);
}

Provide the script with a url parameter inside your ajax request, and
the script should call the proper method depending on this parameter.
You can't interfere with the work of your server script from inside
JavaScript. To ajax, i.e. to http protocol, all you're requesting is
the result of a program. What that program does is irrelevant for it,
as long as it gets the proper result. However, you can provide it with
parameters based upon which the server script can decide what methods
it's going to call.

Thanks Darko (and Rob),

I think I understand. Not sure tho.

So, are you saying that if I include a parameter in the xmlhttp
request that points to the server-side method I will be able to target
that method's response? For example:

req.open("GET", "server.aspx?startMethod=SomeCallback", true);

This doesn't look right. Would somebody mind showing me a code example
of how to do this (your own code or a link)? Sorry, I just want to
make sure I understand this.

Thanks.

Mar 13 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by abcd | last post: by
10 posts views Thread by sheadley | last post: by
4 posts views Thread by Grant Merwitz | last post: by
6 posts views Thread by Scott M. | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.