I was missing dataType: 'json', in the js...
Dave From: Advantage+ [mailto:[email protected]] Sent: Tuesday, October 16, 2012 3:26 PM To: [email protected] Subject: Upgrade 1.3 -> 2.1.3 Issue My app 1.3 version was working fine, now slowly upgrading / converting to 2.1.3 and running into an issue with my JSON response. In 1.3 I clicked "Add to favorite" and the js would update my favorite counter such as Favorites ( 8 ) <- 8 , 9, 10 whatever number of favorite they had saved. Pretty simple. The JSON response was {"count":5} Using js function: $("a.favorite").live("click", function(){ $(this).toggleClass("not"); $.ajax({ type: "POST", url: $(this).attr('href'), success: function(r){ $('a#fav_count span span').html(r.count); } }); return false; }); Rendered HTML for the counter is: <a id="fav_count" href="/profiles/favorite "><span>Favorites(<span >6</span>)</span></a> I have been using this to return my JSON : public function _ajaxReturn( $response = null ) { //original 1.3 version $this->header('Content-Type: application/json'); //new 2.1.3 version //$this->RequestHandler->setContent('json', 'application/json'); echo json_encode($response); exit(); } But for some reason the Favorite counter no longer updates the number. Getting zero errors, check error log, no js errors. The response still comes back as it did in 1.3 but nothing happens to the number count. Any ideas anyone? Thanks, Dave -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. Visit this group at http://groups.google.com/group/cake-php?hl=en.
