I have input on the page where the default value is set to 1. When I click on the button, I pass the value via ajax, the value of this field should be passed to the handler. Spelled in handler
$amount_units = $_POST['amount_units']; but $amount_units = null
How to write in data ? Here is my field and js code
function AjaxCountTotalPriceProduct(amount, total_price_product, total_price_products) { $.ajax({ url: 'http://practice//CountTotalPriceProduct', type: "POST", data: { "amount_units=": amount.value, "total_price_product": total_price_product, "total_price_products": total_price_products }, dataType: "json", cache: false, success: function(response) { $('#amount').val(response[0]); document.getElementById(total_price_product).innerHTML = response[1]; document.getElementById(total_price_products).innerHTML = response[2]; } }); } <div class="col-4 p-0"> <input type="text" class="form-control text-center" id="amount" aria-describedby="emailHelp" oninput="this.value = this.value.replace(/\D/g,'').substr(0,2)" disabled value="1"> </div> <div class="col-3 p-0 text-right"> <button type="button" class="btn btn-secondary" data-toggle="tooltip" title="Увеличить" onclick="AjaxCountTotalPriceProduct('amount', 'total_price_product', 'total_price_products')">+</button> </div>
amountargument to a function? What is transferred there?datais a standard javascript object, the name of the field is simply"amount_units", without=. You can even without quotes. - u_mulderAjaxCount...- u_mulder