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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:48:13+00:00 2026-06-15T03:48:13+00:00

I have a remote form that is populated by jQuery with an AJAX request.

  • 0

I have a remote form that is populated by jQuery with an AJAX request. Then, I am binding this form to an AJAX callback but the callback is not being triggered.

var msgSuccess=function(evt, data, status, xhr){
  alert('ok!!!');
  console.log(evt);
  console.log(data);
  console.log(status);
  console.log(xhr);
}

var bindMsg = function() {   // BIND IT TO THE CALLBACKS
  $("#composeMsgPopup")
  .live('ajax:beforeSend', loadingCallback)
  .live('ajax:success', msgSuccess)
  .live('ajax:error', failureCallback)
  .live('ajax:complete',completeCallback);
}

$.ajax({      // GETTING THE FORM CODE
  url: link,
  type: "get",
  success: function(response, textStatus, jqXHR) {
    ans=response;
    $("#popup_content").html(ans);
    $("#popup").bPopup();
    bindMsg();
  },
  error: function(jqXHR, textStatus, errorThrown) {
    failureCallback(errorThrown, textStatus, jqXHR);
  },
  complete: function(jqXHR, textStatus) {
    completeCallback("", jqXHR, textStatus);
  },
  beforeSend: loadingCallback
});

The code for the form:

<%= form_for(:conversation, :remote => true, 
 :url=> {:controller=>:conversations,:action=>:create},
 :html=>{:id => 'composeMsgPopup' }) do |f| %>
<div id="founder-name" class="field"><b>Recipient: <%= @user.name %></b></div>
<div class="field">
  <%= f.label :subject,"Subject" %>
  <%= f.text_field :subject,:class=>"composeMsgField" %>
</div>
<div class="field">
  <%= f.label :content,"Message Content" %>
  <%= f.text_area :content,:class=>"composeMsgField" %>
</div>
<%= f.hidden_field :to_user, :value => @user.id  %>
<%= f.submit "Send", :class=>"submitbt",:id=>'sendMessage' %>
<% end % >

I have tried to bind with bind() or on() but it does not work. The code is executed but when I submit the form the callback is not executed.

  • 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-15T03:48:14+00:00Added an answer on June 15, 2026 at 3:48 am

    ok i found a solution.
    the remote form not triggering the callback for unknown reason, so what i did is change the
    submit button behaviour:

         <%= f.button :submit, "Update",:class=>"submitbt",:id=>"submitnewpass",:onclick=>"return false;" %>
    

    and bind the button to manually submit the form

     var action=$('#composeMsgPopup')[0].action;   // action url
    $("#sendMessage").click(function() {         // bind submit button
    
        $.ajax({
            type: "POST",
            url: action,
            data: $("#submitnewpass").serialize(), // serializes the form's elements.
            success: function(data)
            {
               // do my stuff
    
            },
            error:      failureCallback,
            beforeSend: loadingCallback,
            complete:   completeCallback
        });
    
        return false;
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

jQuery part: I have a jQuery UI 1.8 Autocomplete form that fetches remote JSON
So i have this form for generating comment_titles: <%= simple_form_for @video, :remote => true
I have a form that uses jQuery-UI's selectable plugin to populate a list from
I have a ListView that is populated with 50 items. This is the xml
I have a form that validates and posts with Ajax, or more specifically, with
I have a simple form that looks like so <% remote_form_for post, :url =>
I am using rails 2.3 and have a problem. I have remote form, and
I have a remote form for updating one of my objects. However, after updating,
I have a contentPane with a remote form, I'm trying to get the form
I have a Rails app and trying to make a remote form, so far

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.