Encontré otro problema con jquery. Vi un código que usa el método .ajax() y la respuesta se selecciona así
.then(response => { $(response).find('.some-selector') })Esto realmente me confunde.
Hice un refactor a vanilla js como este
fetch('/some-endpoint', { method: 'POST', body: new FormData(e.currentTarget) }) .then(res => res.text()) .then(data => { data.querySelector('.some-selector') // does not work })Todo funciona, la respuesta es buena, pero no entiendo cómo obtener el valor seleccionado de los datos.
Primero debes analizar la respuesta:
fetch('/some-endpoint', { method: 'POST', body: new FormData(e.currentTarget) }) .then(res => res.text()) .then(function(html) { const parser = new DOMParser(); return parser.parseFromString(html, "text/html"); }) .then(data => { data.querySelector('.some-selector'); })