开发者

Problem with JSON object in qooxdoo

When I'm sending AJAX query to my webApp, Qooxdoo cannot interpret the response correctly when server return response with header:

Content-Type: application/json; charset=utf-8

Here is sample code:

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();

In this case alert(result) returns to me null (should be object).

Qooxdoo app and server app runs on http://localhost:8080/

If I change mime-type header to:

Content-Type: text/html; charset=utf-8

everything works correctly.

When I add to firefox addition named JSONView then alert(result); returns to me:

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

but server response is:

{"session_id":"31446a34db6961a8d67e4e47c96cfb4","status":200}

So, I think that Qooxdoo use response modified by Firefox, not the pure code returned from serwer. In frameworks like jQuery I've had never开发者_如何学编程 any problems with that.

Is there any solution for this, or should I add jQuery framework and use jQuery ajax requests?

I have: Qooxdoo 1.2.1 and firefox 3.6.12 under Linux.


as you already mentioned the switch from POST to GET is the solution.

Additionally, the setFormField method does internally switch to the IframeTransport implementation. So if you want to use the AJAX transport you should stick with the setParametermethod - as you already do.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜