How it works - Overview
AJAX relies on a broker to dispatch and process requests to and from the server. For this task, the .Net wrapper relies on the client-side XmlHttpRequest object. The XmlHttpRequest object is well supported by most browsers, making it the solution of choice. Since the goal of the wrapper is to hide the implementation of XmlHttpRequest, we'll forgo any detailed discussion about it.
The wrapper itself works by marking .Net functions as AJAX methods. Once marked, AJAX creates corresponding JavaScript functions which can be called client-side (liky any JavaScript functions) and that serve as proxies, using XmlHttpRequest. These proxies map back to the server-side function.
Complicated? It isn't. Let's look at a simplified example. Given the .Net function:
'VB.Net
public function Add(firstNumber as integer, secondNumber as integer) as integer
return firstNumber + secondNumber
end sub
//C#
public int Add(int firstNumber, int secondNumber)
{
return firstNumber + secondNumber;
}
The AJAX .Net wrapper will automatically create a JavaScript function called "Add" which takes two parameters. When this function is called using JavaScript (on the client), the request will be passed to the server and the return value back to the client.

0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home