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

The Archive Base Latest Questions

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

I am trying to call a jquery function on clicking a button in the

  • 0

I am trying to call a jquery function on clicking a button in the form and here is the code I am using

Button code :

  <input type="submit"  src="images/submitbutton.png" alt="Submit button" name="submit_button" class="submit_button" id="submit_button">

Form starting code

 <form method="post" action="" id="contactForm">

The jquery code

<script type="text/javascript">
$(document).ready(function() {

    //if submit button is clicked
    $('input[name=submit_button]').submit(function () {     


alert("testing")

.....

I tried everything to get the submit button to call the jquery function but to no avail ( I tried using submit() or click() ).

What might I be doing wrong ( This form is located on a html page)

Edit : Just inserted the code of the Jquery function I am trying to run ,I am actually trying to call a php script using ajax and then hide the form and provide a success message if the form is submitted successfully

$(document).ready(function() {

    //if submit button is clicked
    $('#submit_button').submit(function () {        

            alert("testing")    /*get the email value*/

var name = $('input[name=name]');
        var email = $('input[name=email]');
        var subject= $('input[name=subject]');
        var message = $('textarea[name=message]');


 data = 'name=' + name.val() + '&email=' + email.val() + '&subject=' + 
        subject.val() + '&message='  + encodeURIComponent(message.val());


        //disabled all the text fields
        $('.text').attr('disabled','true');



        //start the ajax
        $.ajax({
            //this is the php file that processes the data and send mail
            url: "mai.php", 

            //GET method is used
            type: "POST",

            //pass the data         
            data: data,     



            //success
            success: function () {              

                    $('.contact_form').fadeOut('slow');                 

                    //show the success message
                    $('.simple-sucess').fadeIn('slow');

                //if process.php returned 0/false (send mail failed)
                } 



        });

        //cancel the submit button default behaviours
        return false;
    }); 
}); 
</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-28T17:57:33+00:00Added an answer on May 28, 2026 at 5:57 pm

    Well, the name should be in quotes:

    $('input[name="submit_button"]')
    

    http://api.jquery.com/attribute-equals-selector/

    value [..] An attribute value. Quotes are mandatory.

    You should probably be using an ID anyway, though.

    Also, I don’t think you’re meant to be using .submit on the button. Try using .click instead, or .submit on the form.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to call another jQuery function if confirm is true, here's the code:
I'm trying to call a Page Method using a jQuery 'attached' event function, in
I'm trying to call a function that contains jQuery code. I want this function
I am trying to call a user defined function in jQuery: $(document).ready(function() { $('#btnSun').click(function()
I trying to call 2 functions in the same page to submit jquery-ajax at
When I'm trying to call an ascx with Jquery post I get: This type
I am trying to call a WCF RESTful service from jQuery. I am using
I am trying to call to the bit.ly URL shortening service using jQuery with
I trying to make my first AJAX with JSON call using jQuery and CodeIgniter.
I am trying to pass a dataString to to an ajax call using JQuery.

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.