I have a servlet that posts data as an xml page.I made it in Eclipse IDE for Java EE and host it on a Tomcat server. The servlet is hosted on http://localhost:8080/Checkers/CheckersServlet. I can open that url in firefox and it loads the xml fine. How do I call on the servlet from the ajax code?
I think it's supposed to be something like the code below, but that does not work for me. (where displayResult(req) is a custom function that does what I want with the xml received from the servlet). I have confirmed through debugging that the problem is not receiving any xml from the servlet.
Do I need to make one of these web.xml files? Or is that handled by Eclipse when I click "new Servlet"
var req = new XMLHttpRequest();
req.onreadystatechange = function()
{
if(req.readyState == 4)
{
displayResult(req);
}
}
var url = "http://localhost:8080/Checkers/CheckersServlet";
req.open("GET",url,true);
req.send(null);