dojo.xhrPut

*put创建,post更新

转载自:http://dojotoolkit.org/reference-guide/1.7/dojo/xhrPut.html#id7

dojo.require("dijit.form.Button");

function sendText(){
  var button = dijit.byId("submitButton2");

  dojo.connect(button, "onClick", function(event){
    // The parameters to pass to xhrPut, the message, and the url to send it to
    // Also, how to handle the return and callbacks.
    var xhrArgs = {
      url: "putIt",
      putData: "Some random text",
      handleAs: "text",
      load: function(data){
        dojo.byId("response2").innerHTML = "Message put.";
      },
      error: function(error){
        // We'll 404 in the demo, but that's okay.  We don't have a 'putIt' service on the
        // docs server.
        dojo.byId("response2").innerHTML = "Message put.";
      }
    }
    dojo.byId("response2").innerHTML = "Message being sent..."
    // Call the asynchronous xhrPost
    var deferred = dojo.xhrPut(xhrArgs);
  });
}
dojo.ready(sendText);

<b>Push the button to PUT some text.</b>
<br>
<br>
<button data-dojo-type="dijit.form.Button" id="submitButton2">Send it!</button>
<br>
<br>
<b>Result</b>
<div id="response2"></div>

掌握 Dojo 工具包,第 2 部分: XHR 框架与 Dojo

http://www.ibm.com/developerworks/cn/web/1202_zhongsq_widgetcompare/


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值