function reservar() { let telefono = document.getElementById('telefono').value; let texto = document.getElementById('huecos').value; let partes = texto.split('|'); let fecha = partes[0]; let hora = partes[1]; let datos = 'telefono=' + encodeURIComponent(telefono) + '&nombre=' + '&fecha=' + encodeURIComponent(fecha) + '&hora=' + encodeURIComponent(hora); fetch('api/solicitar.php', { method:'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, body:datos }) .then(r=>r.json()) .then(d=> { alert('Solicitud enviada'); }); }