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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:21:57+00:00 2026-05-14T02:21:57+00:00

I was expecting the below scenario common, but couldn’t find much help online. I

  • 0

I was expecting the below scenario common, but couldn’t find much help online. I have a form loaded through Ajax (say, create entity form). It is loaded through a button click (load) event

$("#bt-create").click(function(){
                     $ ('#pid').load('/controller/vehicleModel/create3');
                    return false;
                    });

the response (a form) is written in to the pid element. The name and id of the form is ajax-form, and the submit event is attached to an ajax post request

$(function() {
             $("#ajax-form").submit(function(){
                // do something...
                 var url = "/app/controller/save"
         $.post(url, $(this).serialize(), function(data) {
            alert( data ) ; /// alert data from server
          });

I could make the above ajax operations individually. That is the ajax post operation succeeds if it calls from a static html file. But if I chain the requests (after completing the first), so that it calls from the output form generated by the first request, nothing happens. I could see the post method is called through firebug.
Is there a better way to handle above flow?

One more interesting thing I noticed. As you could see, I use grails as my platform. If I keep the javascripts in the main.gsp (master layout), the submit event would not register as the breakpoint is not hit in firebug. But, if I define the javascript in the template file (which renders the form above), the breakpoint is hit, but as I explained, the action is not called at the controller. I changes the javascript to the head section but same result.

any help greatly appreciated.
thanks,
Babu.

  • 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-05-14T02:21:58+00:00Added an answer on May 14, 2026 at 2:21 am

    You need to register the form submit handler in the success handler of the first ajax request:

    $("#bt-create").click(function() {
        $('#pid').load('/controller/vehicleModel/create3', function() {
            $("#ajax-form").submit(function() {
                // do something...
                var url = "/app/controller/save"
                $.post(url, $(this).serialize(), function(data) {
                    alert( data ) ; /// alert data from server
            });
        });
        return false;
    });
    

    Also I would recommend you using the jQuery form plugin. Your code will look like this:

    $('#bt-create').click(function() {
        $('#pid').load('/controller/vehicleModel/create3', function() {
            $('#ajax-form').ajaxForm(function() {
                alert('thanks for submitting');
            });
        });
        return false;
    });
    

    No need fetch form url, serialize parameters, etc…

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

Sidebar

Related Questions

Outline OK, I have Google'd this and already expecting a big fat NO!! But
I was expecting to find that section within System.Web.Configuration namespace just like other Web.config
The scenario I am facing is that I have an ASP.NET web service (.NET
The below code is very simple. I have a jQuery autocomplete bound to an
I have a Client and Server scenario, where a service is installed on the
Am passing some parameters through in Struts2, and am getting below error when there
Below is the command I tried executing, without success: exec('ln -s ' . PLUGIN_DIR
I always felt that expecting exceptions to be thrown on a regular basis and
Why does the following code not work as I was expecting? <?php $data =
I've installed an OpenType font on my development machine expecting to then be able

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.