I'm trying to pass multiple input values through Ajax jquery but for some unknown reason, it is not working.
For example
<input type="text" class="form-control invoice_item_name" name="invoice_item_name">
<input type="text" class="form-control invoice_item_name" name="invoice_item_name">
jQuery and Ajax
$('.invoice_item_name').each(function(){
var invoice_item_name = $(this).val();
});
$.ajax({
url: 'includes/some-php.php',
type: 'POST',
data: {invoice_item_name:invoice_item_name) {
$('.error_message').html(add_invoice_result);
}
});
some-php.php file
$invoice_item_name = mysqli_real_escape_string($connection, $_POST['invoice_item_name']);
$insert_order_item = "insert into invoice_order_item(order_item_name) values('$invoice_item_name')";
$insert_order_item_query = mysqli_query($connection,$insert_order_item);
Can anyone tell me what am I doing wrong? and I wrapped the "INSERT INTO" query in "for loop". So each item_name stored in the new row.