This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

AJAX part in jsp is not functioning with IE 6.0  RSS feed

Bunty Paul
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I have designed a jsp page and have written a javascript code using ajax so that the data submitted to the servlet is sent through this script code.

The jsp page is responsible to display records. For example,
when the page is loaded it displays about 10 records. When i click the next button it does not communicate with the servlet to give me the next 10 records.

The problem is when i tried to test with IE 6 the data gets retreived only once and for the next retreival it does not communicate with the respective servlet at all. With Firefox the same code works fine.

This is the code...

* This function is used to perform ajax call
* url - url for request
* formNameOrIndex - either formName or formIndex
* namedTag - name of the tag is to be updated

function retrieveURL(url,formNameOrIndex,namedTag) {

tagName = namedTag;
//get the (form based) params to push up as part of the get request

//Do the Ajax call
if (window.XMLHttpRequest) { // Non-IE browsers
req = new XMLHttpRequest();
req.onreadystatechange = processStateChange;
try {"GET", url, true);
} catch (e) {
alert("Problem Communicating with Server\n"+e);
req.send(null);//if method=get
} else if (window.ActiveXObject) { // IE
req = new ActiveXObject("Microsoft.XMLHTTP");
req.onreadystatechange = processStateChange;
try {"GET", url, true);
} catch(e) {
alert("Problem Communicating with Server\n"+e);

* This function used to get reponse from given url when request
status is successful.
function processStateChange() {

if (req.readyState == 4) { // Complete
if (req.status == 200) { // OK response
} else {
alert("Problem with server response:\n " + req.statusText);
}//end if-else
}//end if

* This function used to prepare form-bean
function getFormAsString(formNameOrIndex){

//Setup the return String
returnString ="?";
//Get the form values
//loop through the array , building up the url
//in the form /
for(var i=0;i<formElements.length;i++){
//we escape (encode) each value
return returnString;

* This function used to split response text into given tag and replace existing with new HTML tags.
function splitAndReplace(responseText) {


//split document into tag
splittedElements = responseText.split("</"+tagName+">");

//Process each element
for(var i=0;i < splittedElements.length;i++) {

//check that this begins with <tagName id=
//leave other-tag that having no attribute named id
if((tagPos = splittedElements[i].indexOf("<"+tagName +" id=")) >-1 ){

//remove everything before <tagName id=
if(tagPos > 0) {
subString = splittedElements[i].substring(tagPos);
splittedElements[i] = subString;
}//end if

//get the id of tag
//get the name - between the 1st and 2nd quote mark

//get the content - everything after the first > mark

//alert("name : " + name);
//alert("content : " + content);

//Now update the existing Document with this element
//check that this element exists in the document
document.getElementById(name).innerHTML = content;
} else {
alert("Element:"+name+"not found in existing document");
}//end if-else
}//end if

}//end for

Ben Souther
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to the HTML/Javascript forum where the AJAX gurus hang out.
Eric Pascarello
Posts: 15385
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not a

Well first off open() should be first, than on readystatechange

Is the URl changing for each request? If not it is being cached by the browser. To get around that issue, you would need to add no-cache headers on your serverside page and you can add a timestamp/random number to the url as a querystring parameter. Or you can go with the post instead of a get.

Personally you are wasting lines of code by having an open/send statement for the native object and an open/send statement for the ActiveX. I would say look into prototype.js to do you Ajax calls.

Bear Bibeault
Author and ninkuma
Posts: 66188
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Eric Pascarello:
I would say look into prototype.js to do you Ajax calls.

Second that motion.

I've been using Prototype for some time now, not only for its Ajax simplifications, but its other extensions as well, and it's made my life a lot easier.

Anyone who follows my posts knows I'm very skeptical about 3rd party libraries and frameworks, but Prototype is a great example of a well-thought-out and useful library.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!