我有一張表,我需要檢查數據是否已存在於數據庫中。如果他們這樣做,一個警告圖標應該出現在他們各自的行上的行動欄下的垃圾桶圖標旁邊並顯示關於他們的適當信息。如果DB中存在數據,則顯示警報圖標 - jQuery AJAX
目前,我能夠返回我需要的ajax數據,如果我比較的數據已經存在於數據庫中。但我不會如何在各自的行上顯示圖標。
這是我返回的數據:
{"receive_array":[{"id":"77","batch_id":"45","courier_name":"","vendor_name":"","status":"stored","batch_no":"9","courier_tracking_no":"123"},"",{"id":"126","batch_id":"65","courier_name":"QW12","vendor_name":"Amazon","status":"itemized","batch_no":"18","courier_tracking_no":"QW11"}]}
這裏是我的Ajax:
$.ajax({
type: "POST",
url: window.base_url+'oss/admin/check_receive_data',
data: $.param($('form#receiving-form').serializeArray()),
dataType : 'JSON',
success: function (response) {
//THIS IS WHERE THE PROCESS SHOULD TAKE PLACE
$.each(response.receive_array, function(index, val) {
});
},
error: function (MLHttpRequest, textStatus, errorThrown) {
console.log("There was an error: " + errorThrown);
}
});
編輯:
HTML:
<table id="receiving-box-table" class="table table-hover table-bordered table-striped">
<thead>
<tr>
<th>Courier Tracking #</th>
<th>Courier</th>
<th>Vendor</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<tr>
<td><input type="text" form="receiving-form" class="form-control input-sm track_no" name="courier_tracking_no[]" id="courier_tracking_no_1" /></td>
<td><input type="text" form="receiving-form" class="form-control input-sm" name="courier_name[]" id="courier_name_1" onkeypress="if (event.keyCode == 13) {return false;}"/></td>
<td><input type="text" form="receiving-form" class="form-control input-sm" name="vendor_name[]" id="vendor_name_1" onkeypress="if (event.keyCode == 13) {return false;}"/></td>
<td class="box-action"><button class="btn btn-danger btn-xs clear-data" data-toggle="tooltip" data-placement="right" title="Clear input fields"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span></button></td>
</tr>
</tbody>
</table>
(來自第一行中的行一邊被動態創建。)
任何幫助高度讚賞。謝謝! -Eli
是你不知道如何顯示一個圖標問題或者你現在不知道如何將json中的值與行中的值進行匹配? – Difster
將html粘貼到這裏 –
@Difster我不知道如何在值匹配的同一行顯示圖標。 –