PHP/jQuery – pass value from jQuery Stepper to php page

Two weeks into learning PHP/jQuery – apologies in advance!

I’m using jQuery plugin “jquery.input-stepper.js” to get input value.

//Stepper input
<div class="input-stepper">
    <input class="order_size" type="text" min="0"  max="1000000">

var order_size = $('.input-stepper').inputStepper();

Then on a button click I am hoping to pass the value “order_size” to “Process.php”

      <button id="Button_Up" type="button">Up</button>
            var order_size = $('.input-stepper').inputStepper();

            $(function (){
                    var request = $.ajax({
                                            type: "POST",
                                            url: "Process.php",
                                            data: ({name:order_size})
                                          request.done(function( msg ) {


                                , textStatus) {
                                                alert( "Request failed: " + textStatus );

At this point I’m just trying to verify that the “order_size” value has been passed with the click. I try this on “Process.php” as follows:

$order_size = $_POST['name'];
echo $order_size; 
echo "<BR>"; 

So here’s where I am:

If i remove the line “data: ({name:order_size})” from the button click script then the button fires and “posts” to the Process.php page (I can tell this as the page with the button reloads) however when the line “data: ({name:order_size})” is included then the button does not fire (I can tell this because the page does not reload).

My focus has been on the inclusion of “order_size” inside the POST function, where I am not confident the code is correct.

Any pointers greatly appreciated. 🙂

Resources: I’ve read the following interesting SO questions as well as the documentation for the jQuery Stepper plugin:

PHP + Jquery – pass value through ajax to php and check against variable

How to pass multiple variables to PHP with jQuery

Source: php

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.