prachi munjal 0 Newbie Poster

hi
I am new to AJAX.I am trying to refresh a part of jsp page so that it goes to another jsp page autoamtically after few seconds but i am unable to do this,it remains on the same page and does not get refreshed.Can u please check my code.

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

<script type="text/javascript">
function loadXMLDoc()
{
var xmlhttp;
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","ajax.jsp",true);
xmlhttp.send();
 
}
</script>
</head>
<body>
<div id="myDiv"><h2>Let AJAX change this text</h2></div>
<script type="text/javascript">
window.setInterval( loadXMLDoc(), 200000);
</script>
heeellloooooo

<!--<button type="button" onclick="loadXMLDoc()">Change Content</button>-->
<!-- window.setInterval( loadXMLDoc(), 0.5);-->
</body>
</html>

window.setInterval( loadXMLDoc(), 200000);
Above line should refresh the page after given time..
But I am anable to move to next page

Can this help Anyways?

<% response.addHeader("Refresh","1;http://localhost:6789/line_chart/ajax.jsp"); %>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.