Sat - 24 Oct
Written by Alexander Romanenko
AJAX requests in Zend Framework are no different than regular requests. You can call any controller/action from the background and it will give you an HTML response. However, you probably do not want the unnecessery code that layout and view scripts provide. You could, of course, create separate controllers and viewers specially for AJAX but that's repetitive code we obviously do not want. Manually switching off layout and view scripts on xmlHttp header detection is not pretty too. To the rescue comes
action context switcher that detects the type of request sent and applies appropriate changes to te controller. Watch the video to see how to set it up.
But that is not enough. Once you got ZF to output the desired response, be it XML or JSON, you need to update your front end to accept that response and make sense out of it. In the video I show how you can grap JSON output with a response JavaScript function and put the variables in their right places on the page.
Read more...