Search code examples
asynchronousajaxpro

Asynchronous calls with AjaxPro


I have been working with synchronous calls in AjaxPro, and I am now looking into asynchronous calls. I have been looking at the example Here

My question is : How do I pass variables to my ajaxpro method?

I would like to add some properties to the AjaxMethod MyMethod :

<script type="text/javascript">
function callback(res) {
    alert(res.value);
}
function invokeMyMethod() {
    Namespace.Classname.MyMethod(callback);
}
</script>

Solution

  • Your server-side method will look like this:

    public void MyMethod(int param1, string param2, ...)
    

    You need to call this from the client like so:

    Namespace.Classname.MyMethod(param1, param2, callback);
    

    That should do it.