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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:31:20+00:00 2026-06-12T15:31:20+00:00

I have an ajax form within a parent html form (not my code!). The

  • 0

I have an ajax form within a parent html form (not my code!). The use case scenario is that a user is prompted to enter profile information, opens a pop-up to add multiple contacts to the account, and continues filling out the rest of the profile.

The contacts box allows the user to add a new contact, edit an existing contact, or delete a contact.

The problem is that when the user submits the ajax form for add, edit, or delete, the whole page refreshes, and any unsaved $_POST data in the parent form is lost.

If I hit enter on the page, or Ctrl + $ or Cmd + R, the $_POST data is not lost. These are a few of the articles I have read trying to figure this thing out:

  • https://stackoverflow.com/questions/12734535/ajax-complete-without-page-reload
  • Populating fields in modal form using PHP, jQuery
  • "location.reload()" loses POST/SESSION data? (F5 / Ctrl+R keeps data?)
  • "location.reload()" loses POST/SESSION data? (F5 / Ctrl+R keeps data?))

I’m a PHP developer and a total AJAX newb, so forgive my lack of knowledge here. I tried to mimic the Ctrl+R effect with return false; and location.reload(true), but neither one worked. What am I missing?

Here’s my code for the pop-up box:

$("#contact-dialog").dialog({
    autoOpen: false,
    width: 600,
    modal: true,
    buttons: {
      "Ok": function() {
        var bValid = true;
        allFields.removeClass( "ui-state-error" );

        bValid = bValid && checkLength( contact_first_name, "first name", 2, 64 );
        bValid = bValid && checkLength( contact_last_name, "last name", 2, 64 );
        bValid = bValid && checkLength( title, "title", 1, 64 );
        bValid = bValid && checkLength( phone, "phone", 6, 30 );
        bValid = bValid && checkLength( email_address, "email_address", 5, 128 );

        if ( bValid ) {
          if (contact_count % 2) {
          $( "#contacts" ).append();
          } else {
          $( "#contacts" ).append();
          }
          contact_count++;

          $.ajax({
                type: "POST",
                url: "facility-categories-ajax.php",
                data: { 
                    type: 'add-to-contacts',
                    input: $('#contact-dialog-link').val(),
                    cid: $('#contact-dialog-id').val(),
                    first_name: contact_first_name.val(),
                    last_name: contact_last_name.val(),
                    title: title.val(),
                    phone: phone.val(),
                    email_address: email_address.val(),
                    twitter: twitter.val(),
                    facebook: facebook.val(),
                    linkedin: linkedin.val()
                },
                complete: function(data) {
                    location.reload();
                    return false;
                }
          });

          $(this).dialog("close");
        }
      },
      Cancel: function() {
        contact_update.val('-1');
        $(this).dialog("close");
      }
    },
    close: function() {
      allFields.val("").removeClass("ui-state-error");
      tips.text("");
      if (contact_update.val() > -1) {
        delete_contact(contact_update.val());
      }
    }
  });

I appreciate your help!

  • 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-12T15:31:21+00:00Added an answer on June 12, 2026 at 3:31 pm

    Remove local.reload() to stop the page from being refreshed. You can remove the whole complete: function(){}, because it is only useful for doing things after the ajax call has returned successfully. And consider adding another button such as “Done making changes” that will close the dialog.
    e.g:

     (...)
     buttons: {
        "Done": function() {
            $(this).dialog('close');
        },
    (...)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a small jQuery plugin that I use for form AJAX validation. There
I have an existing HTML form that I'm trying to update to use jQuery.load().
I have a scenario where I need to include an ajax form within another
I have an Ajax form that updates a div when submitted with a submit
I have an Ajax contact form that links to a jquery file but for
I have this problem, I load a page using JQuery ajax, now within that
I have a form in which the Submit button does not sit within the
I have a form within a modal that i am trying to validate before
i have a page loaded via jquery tabs ajax, i have a form within
I have some ajax functions on my default.aspx that I use for saving data

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.