2012-08-07 10 views
0

我用的Qooxdoo REST服務玩,我看到有一個 實驗班http://manual.qooxdoo.org/1.6/pages/communication/rest.html的Qooxdoo其餘實驗

,允許輕鬆創建的通信,但是我找不到任何例子 爲如下:

  1. 如何將有效負載(json)傳遞給put/post請求?
  2. 我怎麼傳遞參數的URL像www.example.com/customers?arg1=20在諮詢

感謝。

+1

時,請參閱http://demo.qooxdoo.org/current/apiviewer/#qx.io.rest.Resource瞭解詳情。 – 2012-08-07 09:58:46

+0

謝謝!我看到1.6版本的文檔...是的,這解決了第一個問題。 – 2012-08-07 10:06:07

+0

如果您自己找到了答案,那麼請不要將其添加到您的問題中。把它放在一個SO答案中,並接受它。 – ThomasH 2012-08-15 08:16:40

回答

0

1.6的文檔並沒有解釋太多,但2.0的文檔提供了一些線索......

申報的具體

var customers = new qx.io.rest.Resource({ 
    create: { 
    method: "POST", 
    url: "/customers" 
    }); 

放/ POST有效載荷:

costumers.create({ "surname": "none", 
        "name": "none", 
        "email": "[email protected]", 
        "description": "nothing", 
        "address": "Southpole" 
}); 

要在url中傳遞參數:

聲明細節

var customers = new qx.io.rest.Resource({ 
    get: { 
    method: "GET", 
    url: "/customers?{args}" 
    }); 

,並呼籲

var arguments = "arg1=10&arg2=10"; 
customers.get({arg:arguments}); 
// this will geneterate the following http://example.com/customers?agr1=10&arg2=10