Send multiple data with jQuery.ajax
<p>I am trying to send multiple data with jQuery.ajax. The combobox <code>product1</code> and the textbox <code>price</code> are working. But when I try to send the text of <code>quantity</code> something goes wrong.</p>

<p><strong>index.php</strong></p>

<pre><code>&lt;?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "database";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn-&gt;connect_error) {
     die("Connection failed: " . $conn-&gt;connect_error);
} 

$sql = "SELECT * FROM forms";
$result = $conn-&gt;query($sql);

if ($result-&gt;num_rows &gt; 0) {
     echo "&lt;select class='form-control select2' id='product1' onChange='getPrice(this.value)' name='product1' style='width: 100%;'&gt;";
     echo "&lt;option selected disabled hidden value=''&gt;&lt;/option&gt;";
     // output data of each row
     while($row = $result-&gt;fetch_assoc()) {
                      echo "&lt;option value='" . $row["id"]. "'&gt;" . $row["naam"]. "&lt;/option&gt;";
     }                   
echo "&lt;/select&gt;";
} else {
     echo "0 results";
}

$conn-&gt;close();

?&gt;
&lt;html&gt;
&lt;body&gt;
&lt;!-- Your text input --&gt;
&lt;input id="quantity" type="text" placeholder="quantity"&gt;

&lt;!-- Your text input --&gt;
&lt;input id="product_name" type="text" placeholder="product_name"&gt;

&lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"&gt;&lt;/script&gt;
&lt;script&gt;
function getPrice() {

    // getting the selected id in combo
    var selectedItem = jQuery('#product1 option:selected').val();

    // Do an Ajax request to retrieve the product price
jQuery.ajax({
    url: 'get.php',
    method: 'POST',
data: 'id=' + selectedItem + ', quantity:document.getElementById('quantity').value,
    success: function(response){
        // and put the price in text field
        jQuery('#product_name').val(response);
        jQuery('#quantity').html(response);        },
    error: function (request, status, error) {
        alert(request.responseText);
    },
}); 
}
&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p><strong>get.php</strong></p>

<pre><code>&lt;?php

// Turn off all error reporting
error_reporting(0);

?&gt;
&lt;?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "database";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname) ;
// Check connection
if ($conn-&gt;connect_error) 
    {
    die('Connection failed: ' . $conn-&gt;connect_error) ;
    } 
else 
    {
    $product1 = filter_input(INPUT_POST, 'id', FILTER_SANITIZE_NUMBER_INT) ;
    $quantity = filter_input(INPUT_POST, 'html', FILTER_SANITIZE_NUMBER_INT) ;

    $query = 'SELECT price * ' . $quantity . ' FROM forms WHERE id=' . $product1 . ' ';

    $res = mysqli_query($conn, $query) ;
if (mysqli_num_rows($res) &gt; 0) 
{
    $result = mysqli_fetch_assoc($res) ;
    echo $result['price'];
}else{
    echo "0 results";
}

    }

?&gt;
</code></pre>

<p>Can someone help me with this?</p>