const loadItems = () => { $.ajax( 'product', { success: data => { const boxes = data.map(product => `

${product.sku}
${product.name}
${product.price} $
${product.attribute}

` ); $('#products').html(boxes.join('\n')); }, error: jqXHR => alert(jqXHR.responseText), } ) } loadItems(); $('#delete-product-btn').on('click', () => { let values = []; const checkboxes = document.querySelectorAll('input[class="delete-checkbox"]:checked'); checkboxes.forEach(checkbox => values.push(checkbox.value)); if(values.length) { $.ajax( `product?id=${values.join(',')}`, { method: 'DELETE', success: loadItems, error: jqXHR => alert(jqXHR.responseText), } ) } else { alert('Please select a product.'); } });