AJAX Page - Debugging for asynchronous callback

Post back data asynchronously

We will use the same example used for the no error handling example.

Here is how we should make a callback with the data correctly:

        ob_post.AddParam("Number1", 49583);
        ob_post.AddParam("Number2", 83924);
        ob_post.post(null, 'onSum', clientFunction);
		
Next we will make the client side function with error handling, depending on the second argument of the function:

        function clientFunction(result, ex){
            if (ex != null){ // equivalent to if (result == null){
                switch (ex.type){
                    case 'InvalidCastException':
                        // the code to execute when one of the arguments is not of the correct type
                        alert ('One of the arguments is not of the correct type.');
                    break;
                    case 'ServerMethodNotImplemented':
                        // the server-side method name is not implemented
                        alert ('The server-side method was not found.');
                    break;
                    case 'MyException':
                        // an error is thrown by the user at server-side
                        alert ('I threw this exception server-side');
                    break;
                    case 'CallbackError':
                        // there was an error server side
                        alert ('There was an error server-side.');
                    break;
                }
            }
            else{
                alert("The sum is: " + result);
            }
        }
		
We will use ShowErrorsAtClient=false and ThrowExceptionsAtClient=true so we can show our own alert messages.

Click to test the correct callback:



If the ServerFileName is misspelled:



If the server method is misspelled:



If one of the arguments is not an integer:



If the numbers are equal:




Download Download this working example.


You may also check the debug for synchronous callback example to see the differences.

"I just discovered your control suite by accident and, after looking at your online demos, I was so impressed that I couldn't resist the temptation to download and put it through its paces. After several hours of experimentation, I congratulate you on a really great product. Your controls are well designed, robust and performance."

Tim Coulter

Random testimonial   All testimonials