I would write some code like this (not tested):
function dateChecker() {
this.firstValue = null;
this.secondValue = null;
this.ondata = null; // used to get notified if data has been received
}
Object.extend(dateChecker.prototype, {
callback: function(res) {
if(res != null && res.value != null) {
this.firstValue = res.Tables[0].Rows[0].one;
this.secondValue = res.Tables[0].Rows[0].second;
}
if(typeof this.ondata == "function") {
setTimeout(this.ondata.bind(this), 1);
}
},
requestDates: function(param1, param2) {
// use arguments only if needed
Namespace.Class.AjaxMethod(param1, param2, this.callback.bind(this));
}
});
So, what you can do now is to create a new instance of this simple class:
var x = new dateChecker();
Now, you have to write your code that should be invoked when the
result is there, always think on asyncronous calls!!
x.oninit = function() {
alert(this.firstValue);
}
To start the request you will write this line:
x.requestDates(param1, param2);
If you need the value later again you can use x.firstValue or x.secondValue.
Regards,
Michael
On 5/3/06, pbd22 <[EMAIL PROTECTED]> wrote:
>
> Thanks for your replies.
>
> what i am trying to do:
>
> 1) user clicks on a calendar date
> 2) server method is called to return that calendar date's "times" from
> the database
> 3) returned values are sorted on the client side and the earliest time
> and latest time are extracted
> 4) the extracted times are returned (return [one, two]) from the
> ClientFuntion_callback method
> and assigned to "r" in getClientFunction().
> 5) getClientFunction()[0] and getClientFunction()[1] is called
> elsewhere in the program which serves the purpose of defining the time
> margins for calendar day.
>
> INeedADip - I tried your suggestions (thank you) and am still getting
> 'undefined' errors.
>
> Michael - I am using a dataset because I dont know what 2 values i need
> until the logic
> on the client side inside ClientFunction_callback(res) sorts through
> the dataset, isolates
> the 2 values i need, and then returns them in the form of 'return [one,
> two]'. I cant do the sorting
> on the server beacuse the logic is dependant on client-side information
> (i took out a lot of code in my above example for simplification).
>
> I currently have code that calls the ajax methods that, i thought,
> solved the problem of method blocking... i am using setTimeout(). I
> guess i need to better understand async vs sync. Would you mind showing
> me how the example i have provided could be coded in the async style?
> maybe this is my problem.
>
>
> >
>
--
Best regards | Schöne Grüße
Michael
Microsoft MVP - Most Valuable Professional
Microsoft MCAD - Certified Application Developer
http://weblogs.asp.net/mschwarz/
http://www.schwarz-interactive.de/
mailto:[EMAIL PROTECTED]
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ajax.NET Professional" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/ajaxpro
The latest downloads of Ajax.NET Professional can be found at
http://www.ajaxpro.info
-~----------~----~----~----~------~----~------~--~---