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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:06:26+00:00 2026-05-24T10:06:26+00:00

I’m fairly new to jQuery and JavaScript, and I’ve been trying to implement a

  • 0

I’m fairly new to jQuery and JavaScript, and I’ve been trying to implement a jQuery contact form which calls to a PHP file to send the actual email.

Here is the jQuery portion which calls the PHP file after the jQuery validation passes:

$(this).click(function() { 

    var result = $.formValidator(options);

    if (result && jQuery.isFunction(options.onSuccess)) {
        options.onSuccess();

        // Start Processor
        if($(this).data('formstatus') !== 'submitting'){

            // Setup variables
                // Form Variables
                    var name = $(".form input#getstarted-name").val();
                    var number = $(".form input#getstarted-phone1").val() + ' ' + $(".form input#getstarted-phone2").val();
                    var company = $(".form input#getstarted-company").val();
                    var email = $(".form input#getstarted-email").val();
                    var message = $(".form textarea#getstarted-message").val();
                    var from_url = $(".form input#getstarted-from_url").val();

                // Consolidate Variables
                var dataString = 'name=' + name + '&number=' + number + '&company=' + company + '&email=' + email + 
                             '&message=' + message + '&from_url=' + from_url;
            var form = $(this),
                //formData = email.serialize(),
                formData = dataString, 
                formUrl = form.attr('action'),
                formMethod = form.attr('method'), 
                responseMsg = $('#startproject-response');

            //add status data to form
            form.data('formstatus','submitting');

            //show response message - waiting
            responseMsg.hide()
                       .removeClass('response-error')
                       .removeClass('response-success')
                       .addClass('response-waiting')
                       .text('Please Wait...')
                       .fadeIn(200);

            $.ajax({
                url: "/layout/js/jquery/forms/form_db_process.php",
                type: formMethod,
                data: formData,
                success:function(data){

                    //setup variables
                    var responseData = jQuery.parseJSON(data), 
                        klass = '';

                    //response conditional
                    switch(responseData.status){
                        case 'error':
                            klass = 'response-error';
                        break;
                        case 'success':
                            klass = 'response-success';
                        break;  
                    }

                    //show reponse message
                    responseMsg.fadeOut(200,function(){
                        $(this).removeClass('response-waiting')
                               .removeClass('response-error')
                               .addClass(klass)
                               .text(responseData.message)
                               .fadeIn(200,function(){
                                   //set timeout to hide response message
                                   setTimeout(function(){
                                       responseMsg.fadeOut(200,function(){
                                           $(this).removeClass(klass);
                                           form.data('formstatus','idle');
                                       });
                                   },3000)
                                });
                    });
                }
            });
        }

        //prevent form from submitting
        return false;

        // End Processor

    }
});

And here’s the PHP file “form_db_process.php”:

$name = mysql_real_escape_string($_GET['name']);
$number = mysql_real_escape_string($_GET['number']);
$company = mysql_real_escape_string($_GET['company']);
$email = mysql_real_escape_string($_GET['email']);
$message = mysql_real_escape_string($_GET['message']);
$ip = $_SERVER['REMOTE_ADDR'];
$timestamp = date("y/m/d : H:i:s", time());
$from_url = mysql_real_escape_string($_GET['from_url']);

// send email etc...

I’ve got this whole thing to work, but I was wondering how to change the GET to POST instead? I know how to do this with regular HTML + PHP, but jQuery I’m at a loss…

I looked here:
http://api.jquery.com/jQuery.post/

But was unable to come up with anything workable/wasn’t sure how to use it.
Any help would be appreciated!!

// EDIT: I’ve added the HTML portion below (for the form):

<form id="startproject-form" class="form" method="post" action="">

<!-- ... form inputs here ... -->

</form>
  • 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-24T10:06:26+00:00Added an answer on May 24, 2026 at 10:06 am

    in jQuery:

    $.ajax({
      type: 'POST',
    

    Your code does:

     $.ajax({
                    url: "/layout/js/jquery/forms/form_db_process.php",
                    type: formMethod,
    

    And formMethod is set earlier:

    var form = $(this),
                    //formData = email.serialize(),
                    formData = dataString, 
                    formUrl = form.attr('action'),
                    formMethod = form.attr('method'), 
    

    Either override it, or actually change your form’s METHOD attribute to POST.

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

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a jquery bug and I've been looking for hours now, I can't
I want use html5's new tag to play a wav file (currently only supported
I have a text area in my form which accepts all possible characters from
I'm trying to create an if statement in PHP that prevents a single post
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
Basically, what I'm trying to create is a page of div tags, each has

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.