$(document).ready(function () { function update_pics(){ $.ajax({ type: "GET", url: '/nikio/pics_list', processData: false, // tell jQuery not to process the data contentType: false, // tell jQuery not to set contentType async: !1, success: (data) => { $('#report_table').empty(); $('#total_pics').text(data['desc']['total_pics']); $('#nn_true').text(data['desc']['nn_true']); $('#nn_err').text(data['desc']['nn_err']); $('#accuracy').text(Math.round(100/(data['desc']['nn_true']+data['desc']['nn_err'])*data['desc']['nn_true'])); for(num in data['data']) { let btn = '' if (data['data'][num]['included'] == true){ btn = '
' } else { btn = '
' } let html_text = ''// html_text += ''+data['data'][num]['init_user']+''+ ''+data['data'][num]['doctor_dianosis']+''+''+data['data'][num]['expert_dianosis']+''+ ''+data['data'][num]['nn_diagnosis']+''+ ''+btn+'' html_text += '' $('#report_table').append(html_text); } exclude_pic(); include_pic(); } }); } update_pics(); $('#recalculate').click(function(){ $.each($('.recalc'), function(e) { console.log($(this).data('pic_id')); var message = { pic_id: $(this).data('pic_id') } $.ajax({ type:'POST', url: '/nikio/recalculate', async: true, processData: false, // tell jQuery not to process the data contentType: false, // tell jQuery not to set contentType data: JSON.stringify(message), success: (data) => { console.log(data); $(this).text(data['data']['nn_diagnosis']); }, error:function (jqXHR, exception) { } }); }); }) function exclude_pic(){ $('.exclude').click(function(){ console.log($(this).data('pic_id')); var message = { pic_id: $(this).data('pic_id') } $.ajax({ type:'POST', url: '/nikio/exclude', async: true, processData: false, // tell jQuery not to process the data contentType: false, // tell jQuery not to set contentType data: JSON.stringify(message), success: (data) => { update_pics() }, error:function (jqXHR, exception) { } }); }); } function include_pic(){ $('.include').click(function(){ console.log($(this).data('pic_id')); var message = { pic_id: $(this).data('pic_id') } $.ajax({ type:'POST', url: '/nikio/include', async: true, processData: false, // tell jQuery not to process the data contentType: false, // tell jQuery not to set contentType data: JSON.stringify(message), success: (data) => { console.log('OK') update_pics() }, error:function (jqXHR, exception) { } }); }); } });