开发者

will_paginate with jquery: respond_to not responding to js request

开发者 https://www.devze.com 2023-01-27 21:22 出处:网络
I am using jquery to paginate my application in the same way facebook and twitter do so. The following will load \"next\" results but it loads the whole html page. It seems it is not responding to the

I am using jquery to paginate my application in the same way facebook and twitter do so. The following will load "next" results but it loads the whole html page. It seems it is not responding to the format.js. What am I doing wrong here?

Home Controller

def index
  @products = Product.paginate(:per_page => 2, :page => params[:page])
  respond_to do |format|
    format.html # index.html.erb
    format.js { render :template => '/products_home.html.erb' } # Prodcuts home partial
  end
end

Jquery Javascript to execute AJAX
$(function() {
  $(".pagination a").live("click", function() {
 var pagination =开发者_Go百科 $(this).parent();
    $(".pagination").html("Page is loading...");
 $.get(this.href, function(data) {
   $('#show').append(data);
   alert('Load was performed.');
   pagination.hide();
 });
    return false
  });
});


See http://api.jquery.com/jQuery.get/

You need to add dataType of "json" to your $.get call.

0

精彩评论

暂无评论...
验证码 换一张
取 消