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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:01:07+00:00 2026-05-31T01:01:07+00:00

I’m kinda new to jQuery, so this may be a silly question… My problem

  • 0

I’m kinda new to jQuery, so this may be a silly question…
My problem is that i have a click event that triggers when I click any button with the class ajax-submit. What I’m trying to do is a simple multi-page form using ajax. It works great on the first step, but the second time I click on a button with the ajax-submit class, it won’t work.

Here is the code I’m using for the AJAX form submitting:

$(document).ready(function() {
$(".ajax-submit").click(function() {
var form_data = $('#unlockForm').serialize();
        $('.ajaxgif').removeClass('hide');
$.ajax({
type: "POST",
url: "formprocess.php",
data: form_data,
success: function(respuesta) {
    $('.ajaxgif').hide();
    $('#process-container').html(respuesta);
},
error: function() {
    $('.ajaxgif').hide();
    alert("Error! Please try again");
}
});
return false;
  });
});

And the form codes are simple like this

<form name="unlockForm" id="unlockForm" method="post">
      <input type="text" onFocus="if(this.value=='Introduce IMEI') this.value=''" value="Introduce IMEI" onBlur="if(this.value=='') this.value='Introduce IMEI';" name="imei" class="textbox part1" id="imei">
    <input type="button" class="ajax-submit inputbutton part1" value="Next" name="simple" id="next-imei">
    </form>

In both forms the buttons have the ajax-submit class, I checked and I don’t have any typo mistake, you may ask why I don’t use submit buttons, well, I tried but I didn’t figured out how to manage the submit event correctly, it kept recharging the page.

  • 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-31T01:01:09+00:00Added an answer on May 31, 2026 at 1:01 am

    The click event is not attached to the new .ajax-submit elements.
    You will need to use delegate event like with on or delegate to do so.

    $("#process-container").on('click','.ajax-submit',function() {
        var form_data = $('#unlockForm').serialize();
        $('.ajaxgif').show(); 
        // I think you didn't really meant: $('.ajaxgif').removeClass('hide');
        $.ajax({
            type: "POST",
            url: "formprocess.php",
            data: form_data,
            success: function(respuesta) {
                $('.ajaxgif').hide();
                $('#process-container').html(respuesta);
            },
            error: function() {
                $('.ajaxgif').hide();
                alert("Error! Please try again");
            }
        });
        return false;
    });
    

    Table of delegate event functions:

    $(selector).live(events, data, handler);                // jQuery 1.3+
    $(document).delegate(selector, events, data, handler);  // jQuery 1.4.3+
    $(document).on(events, selector, data, handler);        // jQuery 1.7+
    

    on Useful docs:

    If selector is omitted or is null, the event handler is referred to as
    direct or directly-bound. The handler is called every time an event
    occurs on the selected elements, whether it occurs directly on the
    element or bubbles from a descendant (inner) element.

    When a selector is provided, the event handler is referred to as
    delegated. The handler is not called when the event occurs directly on
    the bound element, but only for descendants (inner elements) that
    match the selector. jQuery bubbles the event from the event target up
    to the element where the handler is attached (i.e., innermost to
    outermost element) and runs the handler for any elements along that
    path matching the selector.

    Event handlers are bound only to the currently selected elements; they
    must exist on the page at the time your code makes the call to .on().
    To ensure the elements are present and can be selected, perform event
    binding inside a document ready handler for elements that are in the
    HTML markup on the page. If new HTML is being injected into the page,
    select the elements and attach event handlers after the new HTML is
    placed into the page. Or, use delegated events to attach an event
    handler, as described next.

    Delegated events have the advantage that they can process events from
    descendant elements that are added to the document at a later time. By
    picking an element that is guaranteed to be present at the time the
    delegated event handler is attached, you can use delegated events to
    avoid the need to frequently attach and remove event handlers. This
    element could be the container element of a view in a
    Model-View-Controller design, for example, or document if the event
    handler wants to monitor all bubbling events in the document. The
    document element is available in the head of the document before
    loading any other HTML, so it is safe to attach events there without
    waiting for the document to be ready.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have this code to decode numeric html entities to the UTF8 equivalent character.
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

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.