当我发送Ajax查询到我的Web应用程序,的Qooxdoo不能正确地解释响应时头部服务器返回的响应:问题与的Qooxdoo JSON对象
Content-Type: application/json; charset=utf-8
下面是示例代码:
var req = new qx.io.remote.Request("http://localhost:8080/bm/login.json","POST","application/json"); req.setFormField('login',this.loginInput.getValue()); req.setFormField('password',this.passwordInput.getValue()); req.addListener("completed", function(response){ var result = response.getContent(); alert(result); // expected: object alert(result.status); // expected: 200 }, this); req.send();
在这种情况下alert(result)返回给我null(应该是object)。
应用的Qooxdoo和服务器应用上http://localhost:8080/
运行。如果我改变MIME类型头:
Content-Type: text/html; charset=utf-8
一切正常。
当我加入firefox添加名为JSONView然后alert(result);返回到我:
<doctype html=""> <div id="json"> <ul class="obj collapsible"> <li> <span class="prop">session_id</span> : <span class="string">"e4cfcd8e91c567cce3767375dd3fd9d"</span> </li> <li> <span class="prop">status</span> : <span class="num">200</span> </li> </ul> </div> </doctype>
,但服务器的响应是:
{"session_id":"31446a34db6961a8d67e4e47c96cfb4","status":200}
所以,我认为,使用的Qooxdoo响应由Firefox修改的版本,从serwer返回而不是纯粹的代码。在像jQuery这样的框架中,我从来没有遇到任何问题。
有没有解决方案,或者我应该添加jQuery框架并使用jQuery ajax请求?我有: Linux下的Qooxdoo 1.2.1和firefox 3.6.12。
我注意到,当我改变方法类型表单POST到GET并将表单参数设置为URL与req.setParameter(...)一切都很好。 – tchudyk 2010-12-11 15:21:25