Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8254975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T01:22:30+00:00 2026-06-08T01:22:30+00:00

I have a form on my index page that I’m using to sort records,

  • 0

I have a form on my index page that I’m using to sort records, I wanted to add some Ajax functionality to it but for some reason it’s not sending my form parameters as soon as I added Ajax to the mix.

Here’s my form:

<div id="sort-options">
    <%= form_tag uploads_path, :method => "get", :remote => true do %>          
            <%= select_tag "sort", options_for_select([["Creation Date", "created_at"], ["File Name", "name"], ["Rating", "rating_average"], ["Downloads", "downloads"]]) %>
            <%= select_tag "direction", options_for_select([["Descending", "desc"], ["Ascending", "asc"]]) %>                   
            <%= submit_tag "Sort" %>
    <% end %>   
</div>

And my Ajax javascript:

jQuery(document).ready(function($) 
{ 
    $(function () {  
        $('#sort-options input, .pagination a').live("click", function () {  
            $.get(this.href, null, null, 'script');  
            return false;  
        });  
    });

});

When I click the submit button and look at my Firebug console to see what’s happening it’s clear that it’s succesfully calling the Ajax and it serves the page no problem. However it completely ignored my params that are sent and it doesn’t take that into account when it re-queries the database. If I take out the ‘:remote => true’ and remove the link to the Ajax file the params succesfully get sent back to the index action – just no Ajax 🙁

I should add that the Ajax currently works for pagination that I have on the very same page.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T01:22:31+00:00Added an answer on June 8, 2026 at 1:22 am

    The problem is that you bind another click handler to your submit button which overrides Rails’s built-in AJAX functionality (:remote => true). Your selector #sort-options input, .pagination a matches not only pagination links, but also the submit button of the form. Buttons do not have href attributes, which is what you pass to $.get() as a URL. So $.get(this.href, ...) tries to make an AJAX GET request to a null URL (which acts as if it was an empty string, thus the current URL, without any GET params).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So, I have a form on the page that I was using an input
Ok, So I have a form that is on page 'index.html'. The user submits
I have a small app where the index page is a form that instructs
I have a modal window that loads on index page using the following command,
I have the following form: @model Teesa.Models.SearchModel @using (Html.BeginForm(Index, Search, FormMethod.Get, new { id
I have form, where some fields are looks like rows, so I can add/delete
I have an index page with a free form comment field. The Comment field
I have my nice urls working fine and heading to my index.php page, but
I have an index page that detects if users have JavaScript and cookies enabled
I have an erb file named index that has a form in it. As

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.