Prev | Current Page 130 | Next

Rob Allen, Nick Lo, and Steven Brown

"Zend Framework in Action"

We will place the required JavaScript file, reviewFeedback.js, in the ???js??? directory
under web_root. We also need some YUI files, but Yahoo! will serve those for us.
We can break down the client side work into a number of distinct tasks:
Initiate request to server and start a spinner animation
On success:
Update the count
Stop the spinner animation
Say thank you to the user
On failure:
Inform the user
Stop the spinner animation
Licensed to Menshu You
Please post comments or corrections to the Author Online forum at
http://www.manning-sandbox.com/forum.jspa?forumID=329
In order to prevent pollution of the global namespace, we put all the JavaScript code for the review
feedback module into a class called RF (for Review Feedback). The constructor initializes everything and
connects to the server as shown in Listing 4.9.
Listing 4.9: The JavaScript class constructor
function RF(response, reviewId, baseUrl) {
this.id = reviewId;
this.baseUrl = baseUrl;
// turn on spinner and empty the information message
this.startSpinner();
this.message("","");
// ensure that we don't have to encode parameters
var response = parseInt(response); |#1
var reviewId = parseInt(reviewId); |
var sUrl = baseUrl + "/review/feedback/id/"
+ reviewId + "/helpful/" + response;
// perform the request.


Pages:
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
wyświetlacz xperia Wczasy nad morzem baseny ogrodowe tłumacz niemieckiego Restauracje Warszawa