$(document).ready(function () { $('#su_save_clinic_control').on('click', function(){ api_password = $('#api_password').val(); api_username = $('#api_username').val(); rec_balance = $('#rec_balance').val(); clinic_id = $('#clinic_id').val(); demo_clinic = $('#demo_clinic').prop("checked"); email = $('#email').val(); inn = $('#inn').val(); site = $('#site').val(); telephone = $('#telephone').val(); logo = $('#logo').val(); send_directions = $('#send_directions').prop("checked"); accept_direction = $('#accept_direction').prop("checked"); partner_clinic = $('#partner_clinic').prop("checked"); var message = { api_password:api_password, api_username:api_username, rec_balance:rec_balance, demo_clinic: demo_clinic, clinic_id: clinic_id, email: email, send_directions:send_directions, accept_direction:accept_direction, partner_clinic:partner_clinic, inn:inn, site:site, telephone:telephone, logo:logo, areas: [] } $.each($('.area_check'), function(e) { if($(this).prop('checked') == true) message['areas'].push({'id': $(this).data('area_id'), 'enabled': true}) else message['areas'].push({'id': $(this).data('area_id'), 'enabled': false}) }); $.ajax({ type:'POST', url: '/su_save_clinic_control', async: !1, processData: false, // tell jQuery not to process the data contentType: false, // tell jQuery not to set contentType data: JSON.stringify(message), success: (data) => { if(data['success'] == true) { $('#success').slideDown(500); $('#success').delay(2000).slideUp(); } else { $('#exception').slideDown(500); $('#exception').delay(2000).slideUp(); } } }); }); $('#su_delete_clinic').on('click', function(){ clinic_id = $('#clinic_id').val(); var message = { clinic_id: clinic_id } $.ajax({ type:'POST', url: '/su_delete_clinic', async: !1, processData: false, // tell jQuery not to process the data contentType: false, // tell jQuery not to set contentType data: JSON.stringify(message), success: (data) => { if(data['success'] == true) { $('#success').slideDown(500); $('#success').delay(2000).slideUp(); } else { $('#exception').slideDown(500); $('#exception').delay(2000).slideUp(); } } }); }); $('#su_restore_clinic').on('click', function(){ clinic_id = $('#clinic_id').val(); var message = { clinic_id: clinic_id } $.ajax({ type:'POST', url: '/su_restore_clinic', async: !1, processData: false, // tell jQuery not to process the data contentType: false, // tell jQuery not to set contentType data: JSON.stringify(message), success: (data) => { if(data['success'] == true) { $('#success').slideDown(500); $('#success').delay(2000).slideUp(); } else { $('#exception').slideDown(500); $('#exception').delay(2000).slideUp(); } } }); }); });