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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:51:58+00:00 2026-05-27T04:51:58+00:00

I have a php / ajax / javascript form that I am trying to

  • 0

I have a php / ajax / javascript form that I am trying to get to work. With a great deal of help from John Fable, I just need to get the success and error messages to show.
See our thread here:
Putting multiple forms on the same page

My form is at:
http://www.testing123.co.za/try/test-toggle.htm

My object was to get have multiple forms on 1 page, but at the moment when you click submit on either form, the success or error message doesn’t show and instead a loading gif spins near the submit button.

Javascript for the form goes like:

 // JavaScript Document

jQuery(document).ready(function() {
    $('.contactform').submit(function() {
        var action = $(this).attr('action');
        $('.submit', this).attr('disabled', 'disabled').after('<img src="assets/ajax-
loader.gif" class="loader" />');
        $('.message', this).slideUp(750, function() {
            $('.message', this).hide();
            $.post(action, {
                name: $('.name', this).val(),
                email: $('.email', this).val(),
                phone: $('.phone', this).val(),
                dayin: $('.dayin', this).val(),
                dayout: $('.dayout', this).val(),
                comments: $('.comments', this).val(),
                verify: $('.verify', this).val()
            },
            function(data) {
                $('.message', this).html(data);
                $('.message', this).slideDown('slow');
                $('img.loader', this).fadeOut('fast', function() {
                    $(this).remove();
                });
                $('.submit', this).removeAttr('disabled');
                if (data.match('success') != null);
                $('.message', this).show().delay(5000).fadeOut();
            });
        });
        return false;
    });
});

HTML FORM:

<body>

<div id="container">

<div id="accommodation_listing_options_box">

 <ul id="accommodation_listing_options">

  <li>Price Range: <a href="#" class="tooltip" style="cursor:help;" title="Mid-range 
 Accommodation"><img src="../mid-range-yellow.png" width="28" height="19" 
 align="absmiddle" style="padding-left:0px;" /></a></li>

  <li><a href="#">View Comments</a> <img src="../comments_bubble_small.png" width="18" 
 height="16" align="absmiddle" style="padding-left:5px;" /></li>

</ul>

</div>

<div id="quick_enquiry_box">Make Quick Enquiry</div>

<div style="clear:both; width:710px;"></div>



<div style="clear:both;"></div>

<div id="slide_panel">

<div id="contact">

        <form method="post" action="contact.php" name="contactform" id="contactform" 
class="contactform"><div class="message"></div>

<div id="my_contact_left">



        <label for="name" accesskey="U"><span class="required">*</span>Name</label><br 
 />

        <input name="name" type="text" id="name" size="30" class="name" />

        <br />

        <label for="email" accesskey="E"><span class="required">*
  </span>Email</label><br />

        <input name="email" type="text" id="email" size="30" class="email" />

        <br />

        <label for="phone" accesskey="P"><span class="required">*</span>Phone:
 </label><br />

        <input name="phone" type="text" id="phone" size="30" class="phone" />

        <br />

        <label for="dayin" accesskey="P">Day in:</label><br />

        <input name="dayin" type="text" id="dayin" size="30" class="dayin" />

        <br />

        <label for="dayout" accesskey="P">Day out:</label><br />

        <input name="dayout" type="text" id="dayout" size="30" class="dayout" />

 </div>

<div id="my_contact_right">

        <label for="comments" accesskey="C"><span class="required">*</span>Your 
Comments</label><br />

        <textarea name="comments" cols="40" rows="3" id="comments" class="comments" 
style="width: 350px; height:100px;"></textarea>

        <p><span class="required">*</span>Type the validation code in below</p>

        <div style="width:100px; height:40px; float:left;"><label for="verify" 
accesskey="V">&nbsp;&nbsp;&nbsp;<img src="image.php" alt="Image verification" 
border="0"/></label></div>

        <div style="width:310px; height:40px; float:right;"><input name="verify" 
type="text" id="verify" class="verify" size="6" value="" style="width: 50px;" />

        <input type="submit" style="margin-left:112px;" class="submit" id="submit" 
value="Send it!" /></div>

        <div style="clear:both; width:410px;"></div>

</div>

<div style="clear:both; width:710px;"></div>

        </form>

</div>

<div id="quick_form_wrapper_close"><a href="#"><img src="../close-panel-button.gif" 
/></a>
</div>

</div>



<div id="accommodation_listing_options_box">

<ul id="accommodation_listing_options">

  <li>Price Range: <a href="#" class="tooltip" style="cursor:help;" title="Mid-range 
Accommodation"><img src="../mid-range-yellow.png" width="28" height="19" 
align="absmiddle" style="padding-left:0px;" /></a></li>

  <li><a href="#">View Comments</a> <img src="../comments_bubble_small.png" width="18" 
height="16" align="absmiddle" style="padding-left:5px;" /></li>

</ul>

</div>

<div id="quick_enquiry_box2">Make Quick Enquiry</div>

<div style="clear:both; width:710px;"></div>



<div style="clear:both;"></div>

<div id="slide_panel2">

<div id="contact">



        <form method="post" action="contact2.php" name="contactform" id="contactform" 
class="contactform"><div class="message"></div>

<div id="my_contact_left">



        <label for="name" accesskey="U"><span class="required">*</span>Name</label><br 
/>

        <input name="name" type="text" id="name" size="30" class="name" />

        <br />

        <label for="email" accesskey="E"><span class="required">*
</span>Email</label><br />

        <input name="email" type="text" id="email" size="30" class="email" />

        <br />

        <label for="phone" accesskey="P"><span class="required">*</span>Phone:
</label><br />

        <input name="phone" type="text" id="phone" size="30" class="phone" />

        <br />

        <label for="dayin" accesskey="P">Day in:</label><br />

        <input name="dayin" type="text" id="dayin" size="30" class="dayin" />

        <br />

        <label for="dayout" accesskey="P">Day out:</label><br />

        <input name="dayout" type="text" id="dayout" size="30" class="dayout" />

</div>

<div id="my_contact_right">

        <label for="comments" accesskey="C"><span class="required">*</span>Your 
Comments</label><br />

        <textarea name="comments" cols="40" rows="3" id="comments" class="comments" 
style="width: 350px; height:100px;"></textarea>

        <p><span class="required">*</span>Type the validation code in below</p>

        <div style="width:100px; height:40px; float:left;"><label for="verify" 
accesskey="V">&nbsp;&nbsp;&nbsp;<img src="image.php" alt="Image verification" 
border="0"/></label></div>

        <div style="width:310px; height:40px; float:right;"><input name="verify" 
type="text" id="verify" class="verify" size="6" value="" style="width: 50px;" />

        <input type="submit" style="margin-left:112px;" class="submit" id="submit" 
value="Send it!" /></div>

        <div style="clear:both; width:410px;"></div>

</div>

<div style="clear:both; width:710px;"></div>

        </form>

</div>

<div id="quick_form_wrapper_close2"><a href="#"><img src="../close-panel-button.gif" 
/></a>    </div>

</div>

</div>

</body>

The success / error message should appear in the div:

<div class="message"></div> which you can see is in the html form above.

Any ideas why the success / error messages arn’t showing upon submit?

Thanks in advance.

  • 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-27T04:51:59+00:00Added an answer on May 27, 2026 at 4:51 am

    Try this (probably still not 100% correct):

    jQuery(document).ready(function() {
        $('.contactform').submit(function() {
            var action = $(this).attr('action');
            var form = this;
            $('.submit', this).attr('disabled', 'disabled').after(
                  '<img src="assets/ajax-loader.gif" class="loader" />');
            $('.message', this).slideUp(750, function() {
                $(this).hide();
                $.post(action, {
                    name: $('.name', form).val(),
                    email: $('.email', form).val(),
                    phone: $('.phone', form).val(),
                    dayin: $('.dayin', form).val(),
                    dayout: $('.dayout', form).val(),
                    comments: $('.comments', form).val(),
                    verify: $('.verify', form).val()
                },
                function(data) {
                    $('.message', form).html(data);
                    $('.message', form).slideDown('slow');
                    $('img.loader', form).fadeOut('fast', function() {
                        $(this).remove();
                    });
                    $('.submit', form).removeAttr('disabled');
                    if (data.match('success') != null)
                    $('.message', form).show().delay(5000).fadeOut();
                });
            });
            return false;
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a PHP form that uses AJAX to connect to MySQL and
I am trying to fill in a form using Javascript/ajax/php but the problem is
I am trying to implement a Javascript/PHP/AJAX clock into my website so that I
Working on an AJAX website (HTML,CSS,JavaScript, AJAX, PHP, MySQL). I have multiple javascript functions
I have created an form validation using ajax/php. Each text box is validated using
I have a jquery-ajax function that sends data to a php script and the
I have a small AJAX application, written in PHP that I did not secure
I have a basic ajax application, which will not work, instead the php code
Here is what I am trying to accomplish. I have a form that uses
I have a simple HTML form that uses uses ajax in part of 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.