You had manually call the sys method the bottom the page
Using the Microsoft Ajax Library❘851
var authors = eval(‘(‘ + executor.get_responseData() + ‘)’); // Process the authors array here...
Another often - used shortcut is the $addHandler function that points to the addHandler method of the Sys.UI.DomEvent class. This method provides a standard way to subscribe an event handler to an event exposed by a DOM element.
For example, if you want to refactor the previous code to send the WebRequest when the user clicks on a button and display the results on the page, you need an HTML input and a div element:
![]() |
|
---|---|
![]() |
Code fi le [3 - AjaxLibrary\01 - Basics.htm] available for download at Wrox.com |
---|---|
In the btnGetClick function, you can send the request to the server and display the results on the divResult placeholder via its innerHTML property:
![]() |
---|
Code fi le [3 - AjaxLibrary\01 - Basics.htm] available for download at Wrox.com
If you want to manage events, it is important to know the order of the client life - cycle events. The full page life cycle is out of the scope of this book. However, let ’ s touch on this topic because there are some minor (but important) changes in this area.
Earlier in this chapter, you saw examples of how to use the $get function to get a reference to a DOM element by its ID. While the $get function is very useful, modern Web 2.0 applications more and more often need more fl exibility over how DOM elements are selected. The Microsoft Ajax Library 4 introduces a new helper function (named Sys.get ) that allows selecting elements not only by their IDs, but also by their names or CSS classes. Sys.get is also capable of returning references to Ajax Library components.
The Sys.get function expects two parameters: