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 7811787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T04:17:41+00:00 2026-06-02T04:17:41+00:00

I have a problem when sending the Ajax request. When you click on the

  • 0

I have a problem when sending the Ajax request. When you click on the link request is sent to the server 3 times and the answer did not come.

Why the request is sent three times to undermine?

Where did I go wrong in the formation of a query?

code:

run.html.erb

...
<%= link_to "Next", "#", :id => 'next', :class =>
...

run.js.erb

(function(){

  $("#next").click(function(){

    $.ajax({
      type: 'POST',
      url: '/engine/tff',
      success: function(data){
        alert("ok");
        $("#question").html(data);
      }
    });


    return false;
  });
});

controller

def tff
    respond_to do |format|
      format.js render :text => "hello"
    end
end
  • 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-02T04:17:42+00:00Added an answer on June 2, 2026 at 4:17 am

    I am guessing the click event is being bound multiple times probably cos the script is being called multiple times. Not sure what is the reason for the multiple calls as I am not familiar with rails.

    what you could do to avoid it is unbind the click event before binding it or use the on api.

    function ajaxRequest(){
        $.ajax({
          type: 'POST',
          url: '/engine/tff',
          success: function(data){
            alert("ok");
            $("#question").html(data);
          }
        });
        return false;
      }
    

    $("#next").unbind("click").bind("click",ajaxRequest);

    or

    $(document).on("click","#next",ajaxRequest);

    also not sure if you were trying to bind on document ready and there is a typo in your code. but it should be wrapped like this:

    $(function(){
      $("#next").click(ajaxRequest);
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm not sure where the problem is... I have an ajax request that checks
I have a problem when sending asynchronous request to server, the url of server
I have a problem sending POST request with VB6. The code below works properly
I have a problem when trying to send a POST request. The sending method
Is $(*).click(function(){...}) considered expensive? - See here . How about sending an ajax request
I have an ajax request sending some data to a php file: Ext.Ajax.request({ url:
I have a strange problem with native Ajax request invoking. I am creating the
I have a problem with sending some custom headers to with a jQuery ajax
Hi I have a problem in sending data from php to pdf. I think
I have a problem when I want to sending data using byte format in

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.