0

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.

1
  • I've noticed that when I change method type form POST to GET and set form parameters to URL with req.setParameter(...) everything is ok. Commented Dec 11, 2010 at 15:21

1 Answer 1

0

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.