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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:34:28+00:00 2026-05-27T17:34:28+00:00

I’m trying to use AJAX with jquery… this is what I’m trying to do

  • 0

I’m trying to use AJAX with jquery… this is what I’m trying to do :

    <div class="form">
            <form name="contact" class="js-form-contact" action="contact.php" method="post">
                <div class="clearfix">
                    <label>Mail</label>
                    <div class="input">
                        <input type="text" size="44" name="mail"/>
                    </div>

                    <div class="clearfix">
                        <label>Message</label>
                        <div class="input">
                            <textarea rows="6" name="message"></textarea>
                        </div>
                    </div>

                    <!-- recaptcha -->

                    <br/>

                    <div class="submit">
                        <input type="submit" class="btn primary" value="Enviar"/>
                    </div>

                    <div id="quote">
                        <p> :D </p>
                    </div>
                </div>  
            </form>
        </div>          
    </div>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js"></script>
<script type="text/javascript">
    $(document).ready(function(){
        $("btn primary").click(function(){
            $.ajax({
                type: "post",
                url: "contact.php",
                data: $('.js-form-contact').serialize(),
                success: function(data) {                                               
                    $('.js-form-contact .btn primary').attr("disabled", true);
                    $('#quote').html("Rock!!");
                    // $('.column:first-child .box').after('<p class="msg">' + data + '</p>');  
                }
            });         
        });
    });
</script>

the contact.php is just doing “echo “Hello”;” for now. When I click the submit button, the browser goes to contact.php and it echoes “Hello”…

What’s the problem here? , I’m quite new with JS and jQuery so please bare with my noobishness 🙂

  • 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-27T17:34:28+00:00Added an answer on May 27, 2026 at 5:34 pm

    Your jQuery selector is wrong. It should be $(".btn.primary"). The . denotes that it’s a class of the element you’re looking for. No whitespace between classes means the element should have all those classes to match.

    Furthermore, you should probably use event.preventDefault() to prevent the click-event bubbling up to the organic submit handler.

    To put the money where my mouth is…

    // Note the parameter in the click-handler declaration
    $(".btn.primary").click(function (event) {
        event.preventDefault();
    
        // Do ajax magic here
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm trying to create an if statement in PHP that prevents a single post
Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string

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.