Reputation: 14731
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?
Upvotes: 0
Views: 2928
Reputation: 15104
To perform cross-domain requests, e.g. a request to http://localhost:8888/ntlm/authenticate
from a web page served from http://192.168.1.2:8988
, you will either need to enable CORS or use JSONP.
Upvotes: 1