微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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/

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐