Когда я отправляю from, я получаю нулевое значение из формы, используя ajax, В текущей ситуации у меня есть 3 поля, я не получаю никаких значений из формы, Пожалуйста, помогите мне найти решение.
<table class="table table-hover table-centered m-0 table-bordered">
<thead>
<tr>
<th>Sl</th>
<th style="width:10%;">name</th>
<th>email</th>
<th>Date</th>
</tr>
</thead>
<tbody id="purchaseData">
<tr>
<td>1</td>
<td><input type="text" class="form-control" id="quantity" name="name" placeholder="name" required=""></td>
<td><input type="text" class="form-control" id="costPrice" name="email" placeholder="500" required=""></td>
<td><input type="date" class="form-control" id="costPrice" name="email" placeholder="email" required=""></td>
<td>
<button type="button" class="btn btn-primary item-edit" id="btnSave">Submit</button>
</td>
</tr>
<tr>
<td>1</td>
<td><input type="text" class="form-control" id="quantity" name="name" placeholder="name" required=""></td>
<td><input type="text" class="form-control" id="costPrice" name="email" placeholder="500" required=""></td>
<td><input type="date" class="form-control" id="costPrice" name="date" required=""></td>
<td><button type="button" class="btn btn-primary item-edit" id="btnSave">Submit</button></td>
</tr>
</tbody>
</table>
$(function() {
$('#purchaseData').on('click', '.item-edit', function() {
var row = $(this).closest("tr")
var name = row.find("[name=name]").val();
var email = row.find("[name=email]").val();
var date = row.find("[name=date]").val();
$.ajax({
type: "POST",
url: "<?php echo site_url('Con_test/add_purchase_for_shop')?>",
dataType: "JSON",
data: {
'name': name,
'email': email,
'date': date
},
success: function(data) {
if (data == '1') {
var btn = $(this).closest("tr")
var name = inputData.find("button").prop('disabled', false).css(
"background-color", "green");
} else {
var btn = $(this).closest("tr")
var name = inputData.find("button").prop('disabled', true).css(
"background-color", "#2d7bf4");
}
}
});
});
});