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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T14:47:28+00:00 2026-05-29T14:47:28+00:00

I don’t know what is going on here tonight, but I can’t seem to

  • 0

I don’t know what is going on here tonight, but I can’t seem to get AJAX working. When the form is submitted, it refreshes the page with the values in the URL. I’m using a validate plugin that has a submit handler, but it still refreshes. I’ve used this method before and have had no problems. Take a look at the page here and let me know what you think:

http://www.jacobsmits.com/demos/jquery_ajax.html?firstName=&lastName=&email=&message=&contactSubmit=

<div class="demo_content" style="display:none">
    <form id="contact_form">
        <span class="inputSpan">
            <input value="" class="input input1" title="First name" id="firstName" name="firstName" type="text" />
        </span>
        <span class="inputSpan">
            <input value="" class="input input2" title="Last name" id="lastName" name="lastName" type="text" />
        </span>
        <span class="inputSpan">
            <input value="" class="input input2" title="Email" id="email" name="email" type="text" />
        </span>
        <span class="inputSpan">
            <textarea type="text" id="message" name="message" title="Message" class="input textArea" ></textarea>
        </span>

        <span class="inputSpan">
            <input type="submit" name="submit" class="button" id="submit_btn" value="Send" />
        </span>
        <div id="contact_ajax_wrap">
            <div id="contact_ajax_gif" style="display:none;"><img src="http://www.jacobsmits.com/images/main/ajax-loader-black.gif" width="32" height="32" /></div>
            <div id="contact_ajax_success" style="display:none">Thanks! I'll get back to you shortly.</div>
        </div>
    </form>

<script type="text/javascript">
    //This script will handle the email form
    $(window).load(function() {
        $('#contact_form').placeholderRX({textColor: '#999', hoverColor: '#FBFBFB', addClass: 'yourFormInputText'});
    });
    $(".button").click(function() {
        var dataString = "fname=" + $("#firstName").val();
        alert(dataString);
        $.ajax({
            type: "POST",
            url: "http://www.jacobsmits.com/demos/scripts/contact_form.php",
            data: dataString,
            success: function(result) {
                if(result == "Success"){
                    alert("Success");
                }else{
                    alert("Fail");
                }
            }
        });
    });
</script>
  • 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-29T14:47:30+00:00Added an answer on May 29, 2026 at 2:47 pm

    You need to cancel the default behaviour of the submit button(submit the form not ajax).
    It can be done with preverntDefault() on the event object or with return false;

       $(".button").click(function(e) {
            var dataString = "fname=" + $("#firstName").val();
            alert(dataString);
            $.ajax({
                type: "POST",
                url: "http://www.jacobsmits.com/demos/scripts/contact_form.php",
                data: dataString,
                success: function(result) {
                    if(result == "Success"){
                        alert("Success");
                    }else{
                        alert("Fail");
                    }
                }
            });
            return false; /// <=== that was missing.
            e.preventDefault(); /// Or this.
        });
    

    There is a submit event, so better listen to this event instead of the click button:

       $("#contact_form").submit(function(e) {
            var dataString = "fname=" + $("#firstName").val();
            alert(dataString);
            $.ajax({
                type: "POST",
                url: "http://www.jacobsmits.com/demos/scripts/contact_form.php",
                data: dataString,
                success: function(result) {
                    if(result == "Success"){
                        alert("Success");
                    }else{
                        alert("Fail");
                    }
                }
            });
            return false; /// <=== that was missing.
            e.preventDefault();  /// Or this.
        });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Don't know how to explain it better but i'm trying to get a response
Don't know whats exactly going on, but it's definitely killing my time for nothing.
Don't know why this is happening, but after submitting a form via JS (using
Don't know why, but sometimes LocationManager is still working also after closing application. I
Don't know why I can't reply to people on here with only a small
Don't know why but I can't find a solution to this. I have 3
don't know better title for this, but here's my code. I have class user
Don't know a better title but here is what im trying to do. I
I don't know to explain this but here i go, so i have a
don't know if the title describes anything about what I'm trying to say 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.