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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:47:37+00:00 2026-05-25T15:47:37+00:00

I am using a form tutorial that shows how to handle errors and return

  • 0

I am using a form tutorial that shows how to handle errors and return to the page via json. I can see in chrome that the json response is being sent but it is not being displayed in the result div. That is blank. In chrome in the element tab I can see that the information is being inserted just not displayed. If someone could show me why this is happening I would be grateful. Thanks

source showing as entered

<div id="brtv-result" style="display: none; " class="success error">You must enter a service level</div>

jquery

$.ajax({
      type: "POST",
      url: "boxrtrvtemp.php",
      cache: false,
      data: send,
      dataType: "json",
      success: function(msg) {
          $("#brtv-result").removeClass('error');
          $("#brtv-result").removeClass('success');
          $("#brtv-result").addClass(msg.status);
          $("#brtv-result").html(msg.message);
     },
      error:function(){
         $("#brtv-result").removeClass('success');
         $("#brtv-result").addClass('error');
         $("#brtv-result").html("There was an error submitting the form. Please try again.");
     }
   });

the php

<?php

//response array with status code and message
$response_array = array();

//validate the post form

//check the name field
if(empty($authorised)){

    //set the response
    $response_array['status'] = 'error';
    $response_array['message'] = 'Name cannot be blank';

//check the email field
} elseif(empty($serivce)) {

    //set the response
    $response_array['status'] = 'error';
    $response_array['message'] = 'You must enter a service level';

//check the message field
} elseif($department=="Choose Department") {

    //set the response
    $response_array['status'] = 'error';
    $response_array['message'] = 'You must select a department';

//form validated. send email
} elseif($address=="Choose Address") {

    //set the response
    $response_array['status'] = 'error';
    $response_array['message'] = 'You must select a retrieveal address';

//form validated. send email
} elseif(empty($boxnumber)) {

    //set the response
    $response_array['status'] = 'error';
    $response_array['message'] = 'You must enter a box for retrieveal';

//form validated. send email
}else {

    //set the response
    $response_array['status'] = 'success';
    $response_array['message'] = 'All items retrieved successfully';

}

//send the response back
echo json_encode($response_array);

?>
  • 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-25T15:47:38+00:00Added an answer on May 25, 2026 at 3:47 pm

    That’s because you have to show the div i think because it starts out hidden:

    $.ajax({
          type: "POST",
          url: "boxrtrvtemp.php",
          cache: false,
          data: send,
          dataType: "json",
          success: function(msg) {
              $("#brtv-result").removeClass('error');
              $("#brtv-result").removeClass('success');
              $("#brtv-result").addClass(msg.status);
              $("#brtv-result").html(msg.message);
              $("#brtv-result").show()//show it
         },
          error:function(){
             $("#brtv-result").removeClass('success');
             $("#brtv-result").addClass('error');
             $("#brtv-result").html("There was an error submitting the form. Please try again.");
              $("#brtv-result").show()//show it
         }
       });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can someone show me a tutorial of using jquery to display successful form submission
Can someone show me a tutorial of using jquery to display successful form submission
I am using a form that shows different (extra) fields based on the onChange
I am using this tutorial to create a login form http://www.ryancoughlin.com/2008/11/04/use-jquery-to-submit-form/ It authenticates against
First time using Asp.net-mvc and originally followed the NerdDinner tutorial. My form submit button
I'm using form_remote_for() to do validation on a form's data so that my rails
I am using form base authentication in my Sharepoint site. On my login page
I wan't to connect to remote web page (that has login form) with HttpWebRequest.
i am trying to do a simple form that adds a new comment using
i am using form authentication for my website which is written in ASP.Net, but

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.