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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:27:44+00:00 2026-06-17T10:27:44+00:00

I found an ajax form script to display data without reloading the page. Everything

  • 0

I found an ajax form script to display data without reloading the page. Everything is okay but I want to display variable values in a table when the form is submitted. Here is the link that I found Jquery ajax tutorial and below is my code. Please help me.

index.php

<div id="wrapper">
  <form action="" id="demoForm" method="post">
    <fieldset>
      <legend>Demo form</legend>
      <span style="font-size: 0.9em;">This ajax submit demo form.</span>
      <p>
        <label for="email">E-Mail:</label>
        <input type="text" name="email" id="email" value="" />
      </p>
      <p>
        <input type="submit" name="submit" id="submit" style="float: right; clear: both; margin-right: 3px;" value="Submit" />
      </p>
    </fieldset>
  </form>

  <div id="message" style="display: none;"> </div>
  <div id="waiting" style="display: none;"> Please wait<br />
    <img src="images/ajax-loader.gif" title="Loader" alt="Loader" /> 
  </div>

</div>
<script type="text/javascript" src="js/jquery/jquery-1.3.2.js"></script> 
<script type="text/javascript" src="js/ajaxSubmit.js"></script>

ajaxSubmit.php

$(document).ready(function(){
    $('#submit').click(function() {

        $('#waiting').show(500);
        //$('#demoForm').hide(0);
        $('#message').hide(0);

        $.ajax({
            type : 'POST',
            url : 'post.php',
            dataType : 'json',
            data: {
                email : $('#email').val()
            },
            success : function(data){
                $('#waiting').hide(500);
                $('#message').removeClass().addClass((data.error === true) ? 'error' : 'success')
                    .text(data.msg).show(500);
                if (data.error === true)
                    $('#demoForm').show(500);
            },
            error : function(XMLHttpRequest, textStatus, errorThrown) {
                $('#waiting').hide(500);
                $('#message').removeClass().addClass('error')
                    .text('There was an error.').show(500);
                $('#demoForm').show(500);
            }
        });

        return false;
    });
});

post.php

<?php
sleep(3);

if (empty($_POST['email'])) {
    $return['error'] = true;
    $return['msg'] = 'You did not enter you email.';
}
else {
    $return['error'] = false;
    $return['msg'] = 'You\'ve entered: ' . $_POST['email'] . '.';
}

echo json_encode($return);
?>
  • 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-17T10:27:45+00:00Added an answer on June 17, 2026 at 10:27 am

    Try this:

    success : function(data){
        data = JSON.parse(data);
        $('#waiting').hide(500);
        $('#message').removeClass().addClass((data.error === true) ? 'error' : 'success')
            .text(data[0].msg).show(500);
        if (data[0].error === true)
            $('#demoForm').show(500);
    },
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a ajax image upload script which i found here http://www.fengcool.com/2009/06/ajax-form-upload-local-image-file-without-refresh/ The problem
I have implemted AJAX form submission into my webforms before without issue but now
I have an Ajax script that allows me to check a form without refreshing
I am using php/ajax to submit a form without page refresh. Here are my
I am an average newbie to CakePHP. While reading cookbook found Ajax form and
I am writing an ajax navigation script. I found out i could highlight the
found this little code snippet that seems to do what i want, but im
I've found other threads discussing .load and .ajax with Chrome and IE, but none
I'm calling 2 JS functions(Ajax) each of which are returning data from the server.But
This does not work <h:form style=display: inline;> <h:outputLink value=#{title.link} > #{msg['g.readMore']} <f:ajax event=click immediate=true

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.