ajax请求与响应的问题,急~~~~~在线等
index.js这边是这样的:
$(function(){
$.ajax({
url:"http://localhost/ajax",
data:"username=yinjian&password=123",
dataType:"json",
success:function()
{
alert(arguments);
}
});
});
而servlet是这样的
protected void service(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
String username = req.getParameter("username");
System.out.print("username = "+username);
PrintWriter out = resp.getWriter();
out.write("hello "+username);
}
其他配置都没有问题:
如果在浏览器的地址栏输入http://localhost/ajax
返回
[color=#FF0000][/color]hello null
但是
如果我在index.html载入index.js的代码时,却没有响应的数据,这是怎么一会儿事呢??
用firbug的结果
响应头信息
Content-Length 13
Date Thu, 18 Oct 2012 01:38:47 GMT
Server Apache-Coyote/1.1
请求头信息
Accept application/json, text/javascript, */*; q=0.01
Accept-Encoding gzip, deflate
Accept-Language zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3
Connection keep-alive
Host localhost
Origin null
User-Agent Mozilla/5.0 (Windows NT 6.1; rv:14.0) Gecko/20100101 Firefox/14.0.1
响应没任何数据
求大神帮忙~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
------解决方案--------------------