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

231
Vistas
how can i update the div data with xml http request

On my JSP page, I need to get the data from the XML HTTP request,

here is my code,,

<body>
<div id="ptab">
  <button onclick="next()"></button>
</div>

<script>
xmlhttp=new XMLHttpRequest();
    xmlhttp.open("GET","url",false);
  xmlhttp.send(null);
 document.getElementById("ptab").innerHTML=xmlhttp.responseText;
</script>


<script>
function next(){
 var xhttp = new XMLHttpRequest();
  xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
      document.getElementById("ptab").innerHTML = this.responseText;
    }
  };
  xhttp.open("GET", 'url?id=2', true);
  xhttp.send();
}

</script>

</body>

when I click the button, it displays the data getting from the URL but it didn't update the URL with id '2'.

firstly, when the page loads, I have to display the data from the URL. when I click the button, I need to display the data from URL?id='2'

how can I get this,

or any other approaches to fetch the response without refreshing the page

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