gap_tooth_clan (3) [Avatar] Offline
#1
I was having difficulty using the Yahoo YUI I kept getting javascript errors so I replaced it with some JQuery. All you need is the jQuery library from http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js and put this code in review.feedback.js

// perform the request.

$.getJSON(sUrl, function(data) {
$('#counts-'+data.id).html(data.helpful_yes+' of '+data.helpful_total);
$('#yesno-'+data.id).remove();

});

instead of the YUI stuff. This processes on success but has not got a failure script.

My only problem is that the page www/zendbook/kids-days-out/public/review/feedback/format/json/id/1/helpful/0 includes the header, menu and footer. I am assuming this is what is causing me grief is there any way to stop them from being processed?

In Firebug on the net tab you can view the response it is as follows:

{"originalModule":"default","originalController":"review","originalAction":"feedback","result":true,"id" :1,"helpful_yes":"4","helpful_total":"5","menu":[{"title":"Home","url":"/www/zendbook/kids-days-out /public/"},{"title":"Browse Places","url":"/www/zendbook/kids-days-out/public/place/browse"} ,{"title":"Articles","url":"/www/zendbook/kids-days-out/public/articles"},{"title":"About","url" :"/www/zendbook/kids-days-out/public/about"}]}<div id="menu"> <ul id="main_menu"> <li> <a href="/www/zendbook/kids-days-out/public/">Home</a> </li><li> <a href="/www/zendbook/kids-days-out/public/place/browse">Browse Places</a> </li><li> <a href="/www/zendbook/kids-days-out/public/articles">Articles</a> </li><li> <a href="/www/zendbook/kids-days-out/public/about">About</a> </li></ul> </div>
jhartlep (3) [Avatar] Offline
#2
Re: Chapter 5 AJAX, jSon returns menu, header and footer
Try using

if(!$request->isXmlHttpRequest()) { ... }

for your ActionSetup - Class on public function dispatchLoopStartup. Just put your code inside this if-statement...