From a197dec136feae5cbf770f412cb951a62ed62564 Mon Sep 17 00:00:00 2001 From: Mateja Date: Sun, 15 Nov 2020 21:39:32 +0100 Subject: AJAX select special callsign from activities finished. --- public/js/activities.js | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'public') diff --git a/public/js/activities.js b/public/js/activities.js index f9c19ac..94bee2d 100644 --- a/public/js/activities.js +++ b/public/js/activities.js @@ -8,8 +8,31 @@ jQuery('select#call-sign').change(fillTable); jQuery(document).ready(fillTable); function fillTable() { + tableData = jQuery('table#ajax-table>tbody').first(); + tableData.html('Loading...'); + sign = jQuery('select#call-sign').first().val(); + jQuery.post('/api/activities', {'call-sign': sign}, function (data, status) { - console.log(data); + if (status === 'success') { + if (data.data.length > 0) { + tableData.empty(); + for (var i = 0, len = data.data.length; i < len; i++) { + tr = '' + data.data[i].operatorCall + '' + + '' + data.data[i].fromTime + '' + + '' + data.data[i].toTime + '' + + '' + data.data[i].specialCall + '' + + '' + data.data[i].frequencies + '' + + '' + data.data[i].qso + ''; + tableData.append(tr); + } + } + else { + tableData.html('No data...'); + } + } + else { + tableData.html('Error!'); + } }); } -- cgit v1.2.3