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

  • Home
  • SEARCH
  • 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 8392919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:38:50+00:00 2026-06-09T19:38:50+00:00

Need help in jquery: here is a schema of code: submit form through jquery

  • 0

Need help in jquery:

here is a schema of code:

  1. submit form through jquery to php
  2. php sends another form upon submission
  3. again submit form without page refresh and this continues forever.

sample code:

$(document).ready(function()
{
    $(".message-submit-button").click(function(){   
        var element = $(this);
        var Id = element.attr("id");
        var messageinput = $("#messageinput"+Id).val();
        var action = $("#action"+Id).val();
        var dataString = 'messageinput='+ messageinput + '&mobilenumber=' + Id + '&action=' + action;

        if(messageinput=='')
        {
            alert("Please Enter Message");
            document.getElementById('messageinput'+Id).focus();
        }
        else
        {
            $("#flash"+Id).show();
            $.ajax({
                type: "POST",
                url: "insert_message.php",
                data: dataString,
                cache: false,
                success: function(html){
                    $("#flash"+Id).hide();
                    $("#message-content"+Id).replaceWith(html); 
                }
            });

        }
        return false;
    });
});

In above script, please note that the output “html” is none other than a same form with different set of ids.

above code is working fine for first form, but not for the second or so on. Please help for continues form submission.

Note: Upon submission the form to ‘insert_message.php’, it returns another form in a div tag with different set of ids but same inputs and classnames.

  • 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-09T19:38:52+00:00Added an answer on June 9, 2026 at 7:38 pm

    If the form is the same just with different ids, just change the ids. If you must change the form you’ll have to re-attach the event handler or you can use delegation

    $(document).on("click", ".message-submit-button", function(){
    

    http://api.jquery.com/on/

    If your not on jquery 1.7+ you can use delegate instead

    $(document).delegate(".message-submit-button", "click", function(){
    

    http://api.jquery.com/delegate/

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

Sidebar

Related Questions

I need help here. My jQuery code does not return the submit button name
I need help to use jConfirm with this existing code (php & Jquery &
Need a little help with my jquery here I want all my button with
i need help with this. I'am using JQuery's Dynamic Form plug-in, it duplicates my
I need your help again :) I'm trying to do a plugin with jQuery
Here is what the html looks like, I need help writing the jquery? Initially
I need help with jQuery effects, after setting images to a position through style,
I need help understanding the jquery ui autocomplete example found here: http://jqueryui.com/demos/autocomplete/#remote If you
I'm building a contact form and I need help with the jQuery validator. function
I need some jQuery help on a search form I've created. Right now, 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.