function send_order(order, url) { jQuery('.article-comments-list').addClass('fetching'); jQuery.ajax({ url:url, data: {"comment_order": order, "comment_page": jQuery(".pagination em").html()}, success: function(response) { jQuery(".article-comments-list").html(response); }, complete: function(){ jQuery('.article-comments-list').removeClass('fetching') } }); } jQuery(document).ready(function(){ jQuery("#comment_order").change(function(){ var url = jQuery("#page_url").val(); send_order(this.value, url); }); jQuery(".pagination a").click(function(){ url_with_param = jQuery(this).attr('href') + '&comment_order=' + jQuery("#comment_order").find(":selected").val(); jQuery(this).attr('href', url_with_param); }); });