I'm handling a very (VERY) simple ajax error, but I cannot manage to fix it:
I have the following structure:
In my ajax.js file I have a VERY simple function (without parameter, to make things easier)
function makeAjaxRequest() {
http.open('get', 'test.jsp');
http.onreadystatechange = processResponse();
http.send(null);
}
function processResponse() {
alert("Ready State: " + http.readyState);
if(http.readyState == 4){
var response = http.responseText;
document.getElementById('ajaxResult').innerHTML = response;
}
}
And finally, my test.jsp file contains only:
<% out.print("JSP result");%>
In my manager.jsp I call the function but I receive only one "alert" from the processResponse with readyState = 1...
For sure there is something I'm missing in some step.
Could you help? Thanks a lot.
Cheers, Lucas.
EDIT
For sure in my ajax.js file there is also the function to get a xmlHttpObject.
This line is wrong
http.onreadystatechange = processResponse();
Remove the ()
to assign the actual function, not the result of the function.