Using the Cake Ajax/JavaScript helpers means Cake will write your 
JavaScript. Using jQuery means you write it.

Writing your own jQuery means you have more separation and you can keep 
your javascript out of your views and place it in it's own file. Reading as 
much as you can about progressive enhancement and unobtrusive javascript 
will help to.

@advantage+ This is an example of how I do infinite-scrolling sending back 
the same view for both http and ajax requests.

$(function() { 
 var didScroll = false, 
loading = $("#loading");
 $(window).scroll(function() {
   didScroll = true;
}); 
 setInterval(function() {
$paginate = $('#paginate');
if($paginate.length > 0) {
 if (didScroll) {
   didScroll = false;
if ($(window).scrollTop() >= $(document).height() - $(window).height() - 
200) {
var next = $paginate.find('.next a').attr('href');
if (next) {
loading.show();
$.ajax({
dataType: 'html',
  url: next,
success: function (html) {
var $html = $('<html />').html(html);
var resultCount = $html.find("#resultCount");
var results = $html.find("#results");
var paginate = $html.find("#paginate");
$("#resultCount").html(resultCount);
$("#results").append(results);
$("#paginate").html(paginate);
loading.hide();
}
});
}
} 
   }
}
}, 250); 

});



On Friday, May 24, 2013 7:21:45 PM UTC+10, Sam wrote:
>
> Hi Cakephp experts,
>
> I would like to try out Ajax. May I know what are the pros and cons of 
> Cakephp Ajax helper and Jquery? I have never touched ajax and would like to 
> know which is a better choice as a start. Thank you very much.
>

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to