I am new to developing websites. I know that I have to map servlets in the web.xml file. The web.xml file is this
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
<display-name>TestApp</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>Serve</servlet-name>
<servlet-class>Serve</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Serve</servlet-name>
<url-pattern>/TestApp</url-pattern>
</servlet-mapping>
</web-app>
But when I call the jquery $.ajax() function, I get this error.
XML Parsing Error: syntax error Location: http://localhost:8080/TestApp/Serve Line Number 1, Column 1:
The AJAX Call is
$.ajax({
url: "Serve",
type: "POST",
success: function(out){
alert(out);
},
error: function(){
alert("No");
}
});
The problem is the servlet still runs fine. The alert(out) works as expected. Please explain why the browser is showing the error and please tell me a solution.
If this is a duplicate question please give a link to the original question.
file:///, since this is ajax request this can be happen. If you have installed nodejs, you can install a server and see console log