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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:17:50+00:00 2026-05-31T13:17:50+00:00

How to display error message in popup and if success message comes hide all

  • 0

How to display error message in popup and if success message comes hide all the form fields and show success message.

Presently i am doing like this:
Placing a success message above the form and closing it after the form close.
error message div placing above the form i.e inside the success div. Please suggest me the best way. Give some sample code so that i can implement this.

my html code:

<div id="successMessage">
<form method="POST" id="update_form"  onsubmit = "return false;">
    <div id="errorMessage"></div>
    <table align="center">
        <tr>
            <td align="right">First Name:</td>
            <td align="left"><input type="text" name="firstName" value="<?php echo $firstName; ?>" /> 
            </td>
        </tr>
        <tr>
            <td align="right">Last Name:</td>
            <td align="left"><input type="text" name="lastName" value="<?php echo $lastName; ?>" /> 
            </td>
        </tr>
        <tr>
            <td align="right" colspan="2">
                    <input type="hidden" name="userId" value="<?php echo $userId; ?>" />
                    <input type="button" name="updateUserDetails" value="Update" onclick="updateUserDetails();">
            </td>
        </tr>   
    </table>
</form>
</div>

jquery Code:

function editUserDetails(userId, operation){
    currentOperation = operation; 
    $('#editUserDetails').dialog('open');
    $('#editUserDetails').html("Loading...");
    $.ajax({
           type: "POST",
           url: "editUserDetails.php?userId="+userId,                  
           data: "",
           success: function(msg){
               $('#editUserDetails').html(msg);
           },
           error:function(msg){
                 //alert(msg);
                $('#editUserDetails').dialog("close"); 
           }
    });
}

function updateUserDetails(){
        $.ajax({
               type: "POST",
               url: "updateUserDetails.php",                   
               data: $("#update_form").serialize(),
               success: function(msg){
                   if(msg=="Updated Successfully")
                   {
                       $('#successMessage').html(msg);
                   }
                   else
                   {
                       $('#errorMessage').html(msg);
                   }
               },
               error:function(msg){
                    $('#editUserDetails').dialog("close"); 
               }               
         });
    });
});
  • 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-31T13:17:51+00:00Added an answer on May 31, 2026 at 1:17 pm

    First, don’t wrap your form inside the success div, keep it separate like this:

    <div id="successMessage"></div>
    

    Next, in the ajax success function just do this to hide the form and display message:

    success: function(msg){
             if(msg=="Updated Successfully")
             {
                 $("#successMessage").html(msg);
                 $("#update_form").hide();
             }
             else
             {
                 $("#errorMessage").html(msg);
                 $("#errorMessageDialog").dialog();
             }
    }
    

    For the error message it is a little bit trickier. First change the error message div to something like this:

    <div style="display: none;" id="errorMessageDialog">
    <p id="errorMessage"></p>
    </div>
    

    Then in the ajax error function open set the error message and open the dialog like this:

    error:function(msg){
          $("#errorMessage").html(msg);
          $("#errorMessageDialog").dialog();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to show all my validation error's of EdiText fields in a popup
Error message doesn't display on mysql connect failure if( ! $this->remote_connection_id = @mysql_connect($vars['hostname'], $vars['username'],
Is there a way I can display an error message in a popup box?
Under certain circumstances, I wish to display an error message to the user if
I would like to set up an error page which will diplay a message
I am using javascript form validation, and jquery to display the error messaging and
Whenever I POST a form, I display error messages. However, the way I add
I want to spawn another process to display an error message asynchronously while the
I am trying to display an error message as a tooltip as shown in
I'm using the ajax toolkit's ValidatorCalloutExtender to display error messages on a textbox. The

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.