I am confused with Json requests

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

I am confused with Json requests

TimofeyBiryukov
Hello,

I am kinda new to qooxdoo and stuff.

What I was trying to figure out is how do I POST my json to my server.

Look this is the code I wrote:

  var req = new qx.io.remote.Request('http://virt2/login','POST','application/json');
                                req.setRequestHeader("content-type","application/json");
  req.setFormField('name', userName.getValue());
                                req.setFormField('password', userPassword.getValue());
                                req.send();

I whant server to recive Json? but instead I get this:

                        Array
(
    [_data_] => nocache=1352875203070
    [name] => admin
    [password] => admin
)
123

As if it is a POST request.

What do i did wrong?
Reply | Threaded
Open this post in threaded view
|

Re: I am confused with Json requests

Alexander Steitz
Hi,

the reason for this is that the Request class internally changes the transport layer to iframe transport whenever you set a form field (= using the 'setFormField' method).

API Documentation:
        setFormField(String vId, String vValue)

        Add a form field to the POST request.

        NOTE: Adding any programatic form fields using this method will switch the Transport implementation to IframeTransport.
        NOTE: Use of these programatic form fields disallow use of synchronous requests and cross-domain requests. Be sure that you do not need those features when setting these programatic form fields.


Anyway, it's way better to use the "qx.io.request.Xhr" class. That's the new one: it works better and is very-well tested. With this class you can use the "requestData" property to send data to the server.

        http://demo.qooxdoo.org/devel/apiviewer/#qx.io.request.AbstractRequest~requestData

Regards,
  Alex

-----Original Message-----
From: TimofeyBiryukov [mailto:[hidden email]]
Sent: Wednesday, November 14, 2012 7:50 AM
To: [hidden email]
Subject: [qooxdoo-devel] I am confused with Json requests

Hello,

I am kinda new to qooxdoo and stuff.

What I was trying to figure out is how do I POST my json to my server.

Look this is the code I wrote:

  var req = new
qx.io.remote.Request('http://virt2/login','POST','application/json');
                                req.setRequestHeader("content-type","application/json");
  req.setFormField('name', userName.getValue());
                                req.setFormField('password', userPassword.getValue());
                                req.send();

I whant server to recive Json? but instead I get this:

                        Array
(
    [_data_] => nocache=1352875203070
    [name] => admin
    [password] => admin
)
123

As if it is a POST request.

What do i did wrong?



--
View this message in context: http://qooxdoo.678.n2.nabble.com/I-am-confused-with-Json-requests-tp7581959.html
Sent from the qooxdoo mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Monitor your physical, virtual and cloud infrastructure from a single web console. Get in-depth insight into apps, servers, databases, vmware, SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

------------------------------------------------------------------------------
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
_______________________________________________
qooxdoo-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel