Proxy FunctionsContents
API Links
Proxy functions, the third stage of a page's lifecycle, provide a means for exchanging data between the browser and the server using your own Javascript functions. Proxy functions ease the data exchange process by encapsulating the details of the XMLHttpRequest object.
Note: Proxied functions are executed, internally, through Jaxer.Callback; try not to let this confuse you.
Specify That a Function Should Be ProxiedYou can specify that a server function should be proxied to the client by:
// Using runat=
<script type="text/javascript" runat="server-proxy"></script>
// Using the proxy property
function getResult() {
return 42;
}
getResult.proxy = true;
// Adding a server function object to Jaxer.proxies
function getNumber() {
return 42;
}
window.onserverload = function() {
Jaxer.proxies.push(getNumber);
};
Give a Proxied Function Access to the Scripts it NeedsPrior to invoking a proxy function, you can determine which scripts and libraries are available when the function executes by doing the following:
Using JavaScript Libraries During CallbacksYou must update the path reference for jQuery on line 8
Invoke a Proxy Function
For each function that you specified should be proxied, Jaxer automatically embeds a proxy function in the
page it emits to the browser. A proxied function named Using a Proxy Function
By default, all proxy functions are synchronous: the browser waits until the proxy function has returned.
However, you can invoke a proxy function asynchronously by using the async() method and providing
the function that should be called when the proxy function returns; for example, Using an Asynchronous Proxy FunctionUse the Proxy Function's DOM
Every proxy Function's DOM on the server is initially empty and doesn't contain the content of the original page.
This DOM may be used to create and transform HTML content to return to the browser after querying
However, the proxy function must return the new/changed data— it isn't automatically returned to the server and the function's state is discarded after execution. Supported Return ValuesProxied functions can return any value supported in JSON, specifically any of these value types:
|
