I
Ian
Is it possible, when using ICallbackEventHandler, to chain Ajax
requests together, with the callback of the 1st method providing the
client-side function name of the 2nd?
Actually I know the answer to that one is "yes"... the real question
is: is it possible to do this without causing an infinite loop?
On the client, I've got something akin to the following:
function FirstCall() {
var message = 'FirstServerMethodtoRun';
<%=sCallBackFunctionInvocation%>
}
function SecondCallAndFirstMethodsCallbackFunction() {
var message = '2ndServerMethodToRun';
<%=sCallBackFunctionInvocation%>
}
function SecondMethodsCallbackFunction() {
alert("Yaay. We should be done now");
}
function CallbackEvaluator(s) {
eval(s);
}
On the server, sCallBackFunctionInvocation looks something akin to:
Page.ClientScript.GetCallbackEventReference(this,"message",
"CallbackEvaluator", "context", "postBackError", true);
So:
An onClick triggers FirstCall, which runs server-side no problem. That
server-side method returns, as its Callback, a string value that
contains the name of the 2nd method. The 2nd method also runs just
fine, and its Callback returns the name of its callback (the alert
box), which also runs fine.
My problem is that then it starts an infinite loop between the 2nd
callback, and the final alert callback. So, instead of:
Method1 -> Method2 -> Alert
It goes:
Method1 -> Method2 -> Alert -> Method2 -> Alert -> Method2 ->
Alert -> Method2 -> forever.
What have I missed (except maybe the obvious lesson to not try to chain
more than 0 ajax requests together). It doesn't seem that this should
be impossible nor even that problematic, but I can't seem to see how I
get the page to stop infinitely calling methods it's already received a
callback from.
Have tried a variety of JavaScript tricks in here (return false, etc),
but still infinite loops.
requests together, with the callback of the 1st method providing the
client-side function name of the 2nd?
Actually I know the answer to that one is "yes"... the real question
is: is it possible to do this without causing an infinite loop?
On the client, I've got something akin to the following:
function FirstCall() {
var message = 'FirstServerMethodtoRun';
<%=sCallBackFunctionInvocation%>
}
function SecondCallAndFirstMethodsCallbackFunction() {
var message = '2ndServerMethodToRun';
<%=sCallBackFunctionInvocation%>
}
function SecondMethodsCallbackFunction() {
alert("Yaay. We should be done now");
}
function CallbackEvaluator(s) {
eval(s);
}
On the server, sCallBackFunctionInvocation looks something akin to:
Page.ClientScript.GetCallbackEventReference(this,"message",
"CallbackEvaluator", "context", "postBackError", true);
So:
An onClick triggers FirstCall, which runs server-side no problem. That
server-side method returns, as its Callback, a string value that
contains the name of the 2nd method. The 2nd method also runs just
fine, and its Callback returns the name of its callback (the alert
box), which also runs fine.
My problem is that then it starts an infinite loop between the 2nd
callback, and the final alert callback. So, instead of:
Method1 -> Method2 -> Alert
It goes:
Method1 -> Method2 -> Alert -> Method2 -> Alert -> Method2 ->
Alert -> Method2 -> forever.
What have I missed (except maybe the obvious lesson to not try to chain
more than 0 ajax requests together). It doesn't seem that this should
be impossible nor even that problematic, but I can't seem to see how I
get the page to stop infinitely calling methods it's already received a
callback from.
Have tried a variety of JavaScript tricks in here (return false, etc),
but still infinite loops.