Good evening, I'm trying to get a response from an Ajax call using jQuery and servlets, but somehow I always get an error.
If I type the servlet url I get the "You're in!" message, but when I try to use jQuery routine I get "Error requesting page http://localhost:8080/investking/servlet/login". Does anyone know how could I do it? Or at least a better way to communicate jQuery with servlets?
OK, that sounds really odd and unrelated to jQuery. At this point I'd run the page under Firefox with Firebug installed to see what other information can be gathered about the nature of the error. Firebug is absolutely essential to diagnosing Ajax problems.
Uhm, I'm running Firefox 3.0b5 under Ubuntu and Firebug is not ready yet for that version. I've tried to install Firefox 2 but I can't make it work. I suppose I'll have to try with another library... any suggestion?
Wow Bear, that TamperData is amazing! When I press on 'Details' on the first message I can see that the servlet sends back the "You're in!" message, but for some reason seems that jQuery takes it as an error. That first message comes with the 'LOAD_BACKGROUND' flag, but just after it comes another one from http://localhost:8080/investking/ with the load flags 'LOAD_DOCUMENT_URI' and 'LOAD_INITIAL_DOCUMENT_URI'. This second message makes the page reload. Do you know why it happens?
Oh, I forgot to tell you that you're right: the URL I typed into the browser was http://localhost:8080/investking/servlet/login and the URL on Ajax request is /investking/servlet/login. And the page with the request is in the same webapp as the servlet.
Sorry this is late, but if you type the URL into the browser it should run the doGet method of a servlet, but it you submit a form, it should be running the doPost method. A simple call to the doGet from the doPost should fix this problem.
Opps, I thought I read it as $.post instead of $.get, I should learn to read one of these days...nevermind