I have a simple jsp page in which there is an ajax call on an input string which returns the upper case of the string in json. This is working for the first time but not on successive requests. I am using the GET method.

Why is it not working for multiple requests?

Help needed.



7 Years
Discussion Span
Last Post by AbhikGhosh

Most likely the Ajax result is being cached; append a random tidbit to your URL, preferably something like timestamp to have a distinct URL for each request to prevent this caching. If you are using an URL like /YourApp/Upper append it with /YourApp/Upper?t=timestamp .


Thing is i want the AJAX request to be sent on each onclick of the button . this is now only happening on the first instance of the click. If I refresh the page then it happens again, else not. This is due to the fact that there is

AJAX.onreadystatechange = handler

where var AJAX has the xmlhttprequest.

Now the ready state is 4 when the data is loaded from the server and since its value is not changing so the handler function is not getting called.So is there any way to change the status after every server response or any other alternate way?


i have nt tried it out yet..do u mean that i shall give an interval say in milliseconds ,so that 2 clicks will be possibly take more time than the interval?


Your solution looked interesting and I believe it will work but as of now it is not working . My code is :

function show() 
        var x = document.getElementById('inValue').value;

         AJAX.onreadystatechange = handler;
		 AJAX.open("GET","inputProcess.jsp?var="+x+"&psuedoParam="+new Date().getTime());

I am sending a new param on each request but since the ready state is not changing the handler is not getting called .Any suggestions?


ok cool i solved it put

AJAX.onreadystatechange = handler;

after the call.

Thanks a lot

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.