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

230
Views
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
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!