Prev | Current Page 134 | Next

Rob Allen, Nick Lo, and Steven Brown

"Zend Framework in Action"


The failure() call back function is very similar, except that we only need to display a message and stop the
spinner:
RF.prototype.failure = function(o) {
// inform the user of failure and stop the spinner
var text = "Sorry, our feedback system hasn't worked. Please try later.";
this.message("failed", text);
this.stopSpinner();
}
This is all the JavaScript code required for our review feedback system. The server side code is similarly
simple.
4.5.3 The server code
The client side JavaScript calls into the feedback action of the Review controller. This is a standard action like
any other in the system and so is a class function called ReviewController::feedbackAction() that
is stored in ReviewController.php. The most significant difference between an action that responds to an Ajax
request and an action that displays HTML directly is the view code; we do not need any HTML.
The output of the action is an array of JSON ecoded data and so we do not need a view template file at all
and we can assign the data directly to the response. We therefore turn off the view renderer action helper to
ensure that it doesn??™t try and render a complete page. The feedback action function is shown in listing 4.11.
Listing 4.11: ReviewController::feedbackAction() contains the server side Ajax response.


Pages:
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
Kąty Rybackie noclegi trener nlp ceny żywca leczenie alkoholizmu Kołobrzeg