Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

149
Visualizações
JS script not loading on ajax request

I have this function to call a website based on a click

   function toURI(event, that) {
        event.preventDefault();

        const url = that.getAttribute('href');
        var request = new XMLHttpRequest();
        request.open("GET", url, true);
        request.onload = function () {
            if (this.status >= 200 && this.status < 400) {
                // Success!
                document.querySelector("#mainInnerBody").innerHTML = this.response;
                // console.log(this.response);
            } else {
                // We reached our target server, but it returned an error
            }
        };
        request.send();

        //This is where we update the address bar with the 'url' parameter
        window.history.pushState("object", "New Title", url);
    }

When i run this function on every

<a href="http://localhost/new/nav/index.php?bank=option_1"  onclick="toURI(event, this)">
     <div class="dropdown-list__item">Option 1</div>
</a>

And here is what it is fetching in the network tab every time-

enter image description here

Now every time it is requesting css/html everything except the javascript file and that javascript file is inside the body.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda