Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

200
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!