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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T02:05:23+00:00 2026-05-16T02:05:23+00:00

I’ll start off by saying I’m new to jQuery but I am really enjoying

  • 0

I’ll start off by saying I’m new to jQuery but I am really enjoying it. I’m also new to stackoverflow and really loving it!!

The problem:
I’ve created a sub-form with jQuery so that a user may add, then select this information from a dropdown list if it is not already available. I’m unable to POST this data with .ajax(), so that the user can continue to fill out other information on the main form without having to start over.

Sub-Form:

   $(function() {
      $("#add").live('click', function(event) {
      $(this).addClass("selected").parent().append('<div class="messagepop"><p id="close"><img src="img/close.png"></p></img><form id="addgroup" method="POST" action="add_group.php"><p><label for="group">New Group Description:</label><input type="text" size="30" name="grouping" id="grouping" /></p><p><label for="asset_type">Asset Type:</label><select name="asset" id="asset" ><option>Building</option><option>Equipment</option></select></p><p><input type="submit" value="Add Group" name="group_submit" class="group_submit"/></form><div id="result"></div></div>');
      $(".messagepop").show()
      $("#group").focus();
      return false;
  });

  $("#close").live('click', function() {
   $(".messagepop").hide();
   $("#add").removeClass("selected");
   return false;
  });
 });

And here is where I’m attempting to process it:

$(function () {
$('#addgroup').submit(function() {
  $.ajax({
   type: $(this).attr('method'),
   url: $(this).attr('action'),
   data: $(this).serialize(),
   success: function(responseText) {
    $('#result').html(responseText);
    }
   });
    return false;
 });
});

I’ve even attempted to create a simple alert instead of processing the information and this also does not work. Instead the form sumbits and refreshes the page as normal. Can anyone help me understand what I am missing or doing wrong? Thank you!

New attempt:

$("#add").live('click', function(event) {
   var form = $("<form>").html("<input type='submit' value='Submit'/>").submit(function(){
   $.post("add_group.php", {grouping: "Building, asset: "STUFF"});
   $(".newgroup").append(form);
   return false;
});

Final code

$(function() {
    var id = 1
    $("#add").live('click', function(event){
        if($(".addgroup,").length == 0){
            $("#test").append('<div class="addgroup"><label for="newGroup">New Group:</label><input type="text" class="newgroup" id="' + ++id + '" /><input type="submit" value="Add Group" name="group_submit" class="group_submit"/></div>');
            $("#add").attr("src","img/add_close.png");
        }else{
            $("#add").attr("src","img/add.png");
            $(".addgroup").remove();}
        return false;
    });

});

$(function(){
    $(".group_submit").live('click',function(event){
        $.ajax({
            type: "POST",
            url: "add_group.php",
            data: {new_group: $(".newgroup").val(), asset: $("#group option:selected").text()},
            success: function(){}
        });
        $(".addgroup").remove();
        $('#subgroup').load('group.php', {'asset': $("#group option:selected").text()});
        return false;
    });
});
  • 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-16T02:05:23+00:00Added an answer on May 16, 2026 at 2:05 am

    If the form is submitting and refreshing as normal, the jquery isn’t kicking in (the refresh means it’s posting the form normally).

    I for some reason (maybe others haven’t) found that $(document).ready(function() { works much better than $(function() { …

    Also, the groups that you’re adding should have a definitive id:
    on #add click, count up a counter (form++) and add that to the id (#addGroup_+form) and then target that straight away in the function that added it:

     $("#group").focus();
     $("#addGroup_"+form).submit(function() {
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a jquery bug and I've been looking for hours now, I can't
Specifically, suppose I start with the string string =hello \'i am \' me And
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms

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.