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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T12:48:26+00:00 2026-05-20T12:48:26+00:00

Just started using AJAX today via JQuery and I am getting nowhere. As an

  • 0

Just started using AJAX today via JQuery and I am getting nowhere. As an example I have set up a job for it to do. Submit a form and then display the results. Obviously I haven’t got it right.

The HTML.

<form id="PST_DT"  name="PST_DT" method="post">
<input name="product_title_1682" id="product_title_1682" type="hidden" value="PADI Open Water">
<input name="product_title_1683" id="product_title_1683" type="hidden" value="PADI Advanced Open Water">

<input type="submit" name="submit" id="submit" value="Continue" onclick="product_analysis_global(); test();"/>

</form>
<span id="results"></span>

There are actually many more fields all loaded in dynamically. I plan to use ajax to submit to PHP for some simple maths and then return the results but we can worry about that later.

The JQuery

function test() {

    //Get the data from all the fields
    var alpha = $('#product_title_1682').val();
    JQuery.ajax({
        type: 'POST',
        url: 'http://www.divethegap.com/update/functions/totals.php',
        data: 'text=' + alpha,
        beforeSend: function () {
            $('#results').html('processing');
        },
        error: function () {
            $('#results').html('failure');
        },
        timeout: 3000,

    });
};

and the PHP

<?php
$alpha = $_POST['alpha'];
 echo 'Marvellous',$alpha;
       ?>

That’s my attempt and nothing happens. Any ideas?

Marvellous.

  • 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-20T12:48:26+00:00Added an answer on May 20, 2026 at 12:48 pm

    First of all, you’re passing the $_POST variable as ‘text’ while your script is looking for $_POST['alpha']. If you update your PHP to $_POST['text'], you should see the proper text.

    Also, if your form is going to have lots of inputs and you want to be sure to pass all of them to your AJAX Request, I’d recommend using jQuery’s serialize() method.

    data: $('#PST_DT').serialize(), // this will build query string based off the <form>
    // eg: product_title_1682=PADI+Open+Water&product_title_1683=PADI+Advanced+Open+Water
    

    In your PHP script you’d then need to use $_POST['product_title_1682'] and $_POST['product_title_1683'].

    UPDATE Add a success callback to your $.ajax call.

    function test() {        
    
        // serialize form data
        var data= $('#PST_DT').serialize();
    
        // ajax request
        $.ajax({
            type  : 'POST',
             url  : 'http://www.divethegap.com/update/functions/totals.php',
             data : data,
             beforeSend : function() {
                 $('#results').html('processing');
             },
             error : function() {
                 $('#results').html('failure');
             },
             // success callback
             success : function (response) {
                 $('#results').html(response);
             },
             timeout : 3000,
        });
    
    };
    

    In your PHP script you can debug the information sent using:

    var_dump($_POST);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am just getting started creating an AJAX application using server side push. I
I have started using ajax/jQuery in our websites / application. There are many plugins
Have just started using Google Chrome , and noticed in parts of our site,
Have just started using Visual Studio Professional's built-in unit testing features, which as I
I just started using SVN, and I have a cache directory that I don't
I just started using CCNet, and in the process of getting my build projects
I have just started using the AsyncController in my project to take care of
I'm using Asp.net and have just started to look for a tab solution and
I just started using XNA Framework 4.0 today, and I was wondering what the
I have just started using services in Android and I have a made a

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.