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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:47:59+00:00 2026-06-17T21:47:59+00:00

Form is dynamically loaded via ajax. After form is loaded I calling initialization of

  • 0

Form is dynamically loaded via ajax. After form is loaded I calling initialization of my small form plugin.
Serialize works only first time but if form has required fields errors second submit is triggered but serialize gives empty string.
This problem occurs only in Firefox. Works ok in Chrome, IE, Safari

My small Form plugin:

App.Forms = (function (parent, $) {

// Default config
var config = {
    form            : '.ajax-form',
    control         : null,
    successCallback : function () {},
    errorCallback   : function () {}

}, _submitForm = function ($form) {

    console.log('--------------- FORM DATA STRING -----------------');
    console.log($form.serialize());
    console.log('--------------------------------------------------');

    $.ajax({
        type    : $form.attr('method'),
        url     : $form.attr('action'),
        data    : $form.serialize(),
        cache   : false,
        success : function (response) {

            if (config.control === null) {
                $form.hide().html(response).fadeIn(800);

            } else {
                $(config.control).hide().html(response).fadeIn(800);
                //                    console.log(response);
            }

            if ($(response).find('.field-validation-error')) {
                App.Placeholder.init();  // Generate placeholder if browser not support
                config.errorCallback.call();
            } else {
                config.successCallback.call();
            }

        }
    });
};

parent.init = function (options) {

    $.extend(config, options);

    var $form = $(config.form);

    if (!$form.length) {
        return false;
    }

    App.Placeholder.init();  // Generate placeholder if browser not support

    $form.on('click', ':submit', function (e) {
        e.preventDefault();
        _submitForm($form);
    });

    return parent;
};

return parent;  }) (App.Forms || {}, jQuery);

Form:

@using N2Project @model N2Project._Essence.Models.RegisterModel  @using (Html.BeginForm("Register", "LoyaltyLogin", FormMethod.Post, new { @id = "register-form" })) {
<p>
    <span class="error">@ViewBag.Error</span>
    <span class="success">@ViewBag.Success</span>
</p>

<p>
    @Html.TextBoxFor(m=>m.Loyaltycard,new{@placeholder="Card Number", @class="size100"})
    @Html.ValidationMessageFor(m=>m.Loyaltycard)
</p>

<p>
    @Html.TextBoxFor(m=>m.FirstName,new{@placeholder="First Name", @class="size100"})
    @Html.ValidationMessageFor(m=>m.FirstName)
</p>

<p>
    @Html.TextBoxFor(m=>m.LastName,new{@placeholder="Last Name", @class="size100"})
    @Html.ValidationMessageFor(m=>m.LastName)
</p>

<p>
    @Html.TextBoxFor(m=>m.DOB,new{@placeholder="Date of birth", @class="size100", @id="dob"})
    @Html.ValidationMessageFor(m=>m.DOB)
</p>

<p>
    @Html.TextBoxFor(m=>m.Email,new{@placeholder="Email", @class="size100"})
    @Html.ValidationMessageFor(m=>m.Email)
</p>

<p>
    @Html.PasswordFor(m=>m.Password,new{@placeholder="Password", @class="size100"})
    @Html.ValidationMessageFor(m=>m.Password)
</p>


<p class="checkbox">
    <input type="checkbox" id="subscribe" name="Subscribe" value="true" />
    <label for="subscribe">
        By registering you agree to recieve news and promotions from Essence via email
    </label>
</p>

<p>
    <button href="#" type="submit" class="btn size100">Send</button>
</p> }
  • 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-17T21:48:00+00:00Added an answer on June 17, 2026 at 9:48 pm

    Problem fixed with this:
    _submitForm($(this).closest(‘form’));

    When I calling submitForm private method I’m passing closest form, and it’s working.

    Can someone explain why it’s working? Why us not working in firefox in first situation ?

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

Sidebar

Related Questions

I load a form and dynamically populate a select via AJAX from a PHP
jQuery elements like Ibuttons does not work when its dynamically loaded via an ajax
I am using jquery validate plugin to validate dynamically loaded form. For some cases
I am trying to using a jquery.validate.unotrusive.js plugin to dynamically created form fields like:
I have a page that gets updated dynamically using ajax, I have a form
I have a list of items which is dynamically updated via an ajax call
I'm writing a form that has some text input elements loaded dynamically when a
I am using plupload in a from which is loaded dynamically through AJAX and
I have a page that loads an HTML form via a $.ajax request. The
I have a Django form which I load dynamically to a jQuery dialog after

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.