If you choose to make a callback with the data asynchronously, when the callback is done,
a client-side function is called.
With this function you can process the data returned by the server.
The function name is sent as the third parameter of the post
(if this parameter is missing, the callback is done synchronously).
The syntax is:
ob_post.post(null, "myServerMethod", myFunction);
In our next example we will send at the server the number 4556, on the server it adds 1000 to it and returns the response to the client.
If you want to execute a function depending on the response from the server
(such as an alert of the result or including parts of the result)
the function must have a parameter that will receive as value the response from the server.
This value can be of any type, thus you can manipulate it as you wish.
Here is an example of a function that alerts the data received from the server:
function myFunction(result, ex)
// if there was no error
if (ex == null)
// process response here
alert("Data received from the server: " + result);
Click to test:
Note: Variable ex holds any error that might have occured.
Please visit the Test and Debug tutorial for details.