ajax问题 - 200确定在firebug但红色消息没有反应体 [英] ajax problem - 200 OK in firebug but red message with no response body

查看:255
本文介绍了ajax问题 - 200确定在firebug但红色消息没有反应体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



在localmachine上,我在注册文本字段中创建了一些带有ajax的HTML示例:
用户类型用户名,
在每个击键ajax发送它到
本地Tomcat,其中servlet检查,如果该用户名已经使用
并发送已采取回应。



在localhost上没有问题。
一旦我类型使用'用户名'servlet发送'taken'响应
和浏览器显示它。



但是,当我把test html页面ajax
在远程机器(一些免费托管远程网络)
在我的localhost Tomcat发送验证请求,
连接,
在Tomcat控制台,我看到请求,
和在firebug在Mozzila这是控制台输出:

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

...但在响应标签
不是servlet响应'taken'
和firebug中的消息是红色



因此服务器通信良好,没有防火墙问题,响应 200 OK

但响应正文为空。



任何想法这个红色消息在firebugs是什么?



非常感谢你。 >

如果任何人都可以推荐一个关于java
的一个严肃的ajax教程,将非常感谢:)

解决方案

您需要在Ajax请求中使用域相对网址:

 / Dinamicki1 / UsernameServlet?username = zik 

或上下文相对URL(假设页面由 / Dinamicki1 提供):

 UsernameServlet?username = zik 

好吧,实际上没有真的一个。这些只是两个单独的技术。但我建议自己开始使用 jQuery (对于客户端)和 Google Gson (对于服务器端)和 JSON (作为客户端和服务器之间的通信语言)。


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 :)

解决方案

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", well there's actually not really one. Those are just two separate technologies. I would however recommend to get yourself started with jQuery (for the client side) and Google Gson (for the server side) and JSON (as communication language between client and server).

这篇关于ajax问题 - 200确定在firebug但红色消息没有反应体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆