I am trying to retrieve from a servlet using Jquery
$(document).ready(function() {
$("#mybutton").click(function(event) {
alert('1');
$.get("http://localhost:8888/ntlm/getuser", function(data) {
alert('data ' + data);
$(".errorMssg").text("Data Loaded: " + data);
alert('data ' + data);
});
return true;
});
});
and in GetUser servlet I have
public void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException,
IOException {
response.setContentType(CONTENT_TYPE);
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.print("Authenticating?");
}
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException,
IOException {
doGet(request, response);
}
If I directly access http://localhost:8888/ntlm/getuser
, I am able to see output, however when I calling using Jquery, not able to see the output.
What could be the reason for this?