I have a servlet that reads data out of a text file and sends that data as an xml page. The servlet is hosted on http://localhost:8080/Checkers/CheckersServlet
. I made it in Eclipse IDE for Java EE and host it on a Tomcat server. I can open that url in firefox and it loads the xml fine. How do I call on the servlet from the ajax code. Do I write something like
var req = new XMLHttpRequest();
req.onreadystatechange = function()
if(req.readyState == 4)
var url = "http://localhost:8080/Checkers/CheckersServlet";
where displayResult(req) is a custom function that does what I want with the xml received from the servlet? This is the code I am trying to use but it isn't working, and I've confirmed the reason is that I am not getting any xml from the servlet.