Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

202
Vistas
GET request works in development, not in production

I have written the following script that should run a GET request to a specific URL when a set of checkboxes are ticked on and off. It works perfectly locally but in Production, I get a 404 response.

Any idea why and how to fix it?

/**
* Remove all child nodes from an element
* @param {Object} element The element to empty
*/
function empty (element) {
    var children = Array.prototype.slice.call(element.childNodes);

    children.forEach(function (child) {
        element.removeChild(child);
    });

}

function toggleItem(toggler, itemType, itemUrl, itemState, itemSource) {
    let outputDiv = toggler.parentNode.querySelector('.theme-park-item-toggler-output');
    empty(outputDiv);

    let xhr = new XMLHttpRequest();
    xhr.open('GET', itemUrl);
    xhr.send(null);

    xhr.onreadystatechange = function () {
        if (xhr.readyState === 4) { // 4 means "Done"
            if (xhr.status === 204) { // 204 means processed successfully with no content returned
                console.log('success');

                if (itemState == true) {
                    let img = document.createElement('img');
                    img.src = itemSource;
                    outputDiv.appendChild(img);
                }
            } else {
                console.log('Failure to toggle');
                toggler.toggleAttribute('checked');
            }
        }
    };
}

document.addEventListener("turbo:load", function() {
    document.querySelectorAll('.theme-park-item-toggler').forEach(function(the_toggler) {
        the_toggler.addEventListener('change', function(e) {
            toggleItem(the_toggler, the_toggler.dataset.type, the_toggler.dataset.url, e.target.checked, the_toggler.dataset.source);
        });
    });
});
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda