Prev | Current Page 131 | Next

Rob Allen, Nick Lo, and Steven Brown

"Zend Framework in Action"


YAHOO.util.Connect.asyncRequest('GET', sUrl, this); #2
}
<#1: Using parseInt() we can avoid having to encode the parameters.>
<#2: The constructor initiates the Ajax call back to the server.>
JavaScript??™s object model is a little different from PHPs and to create a class, we don??™t need a ???class???
keyword, we just need a function which will act as the constructor. The rest of the class??™s functions are then
added to the ???prototype??? property of the function which will make them available to all instances of the class.
Appendix B of Ajax in Action has more details if you need to catch up on your JavaScript object model.
As you can see in Listing 4.9, when we initiate the Ajax call with asyncRequest, we pass in the ???this??? as
the callback object. This means that we must define the member functions success() and failure() so that the
YUI system can call them when appropriate. The advantage of using an instance is that we can store the
reviewId and the baseURL into the instance and they will be available in the member functions when we need
them. We can also provide helper functions within the class to keep the main call back functions easier to read.
We need to provide a message on success and on failure, so it makes sense to write a function called
message():
RF.


Pages:
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
motoryzacja szkoła narciarska wyrejestrowanie samochodu legnica obciążniki Wczasy nad morzem