prachi munjal 0 Newbie Poster

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" "">
<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();
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
<div id="myDiv"><h2>Let AJAX change this text</h2></div>
<script type="text/javascript">
window.setInterval( loadXMLDoc(), 200000);

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

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.