Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ajax problem - 200 OK in firebug but red message with no response body

Tags:

I have small ajax problem related to cross domain as i see it.

On localmachine i created html example with some ajax: in registration text field user types 'username', on every keystroke ajax sends it to local Tomcat, where servlet checks if that username is already used and sends 'taken' reponse back.

No problem on localhost at all. As soon as i type used 'username' servlet sends 'taken' response and browser displays it.

But, when i put test html page with ajax on remote machine (some free hosting on remote network) that sends validation request on my localhost Tomcat, connection is made, in Tomcat console i see request comming, and in firebug in Mozzila this is Console ouput:

GET http://89.216.182.25:8080/Dinamicki1/UsernameServlet?username=zik 200 OK

...but in response tab there is not servlet response 'taken' and message in firebug is in red color

So servers communicate well, no firewall problems, response is 200 OK
But response body is empty.

Any ideas what this red messages in firebugs are?

Thank you very much in advance.

And if anyone can recommend a some serious ajax tutorial for java it will be highly appreciated :)

like image 324
reg Avatar asked Feb 08 '10 02:02

reg


1 Answers

You need to use a domain-relative URL in your Ajax request:

/Dinamicki1/UsernameServlet?username=zik

Or a context-relative URL (assuming that the page is served from /Dinamicki1):

UsernameServlet?username=zik

With regard to "Ajax tutorial for Java", start here: How to use Servlets and Ajax?

like image 119
BalusC Avatar answered Oct 21 '22 11:10

BalusC