zoukankan      html  css  js  c++  java
  • dogo 官方翻译 Ajax with dojo/request

    require(["dojo/request"], function(request){
        request("helloworld.txt").then(
            function(text){
                console.log("The file's content is: " + text);
            },
            function(error){
                console.log("An error occurred: " + error);
            }
        );
    });
    require(["dojo/request"], function(request){
        request.post("post-content.php", {
            data: {
                color: "blue",
                answer: 42
            },
            headers: {
                "X-Something": "A value"
            }
        }).then(function(text){
            console.log("The server returned: ", text);
        });
    });
    require(["dojo/dom", "dojo/on", "dojo/request", "dojo/domReady!"],
        function(dom, on, request){
            // Results will be displayed in resultDiv
            var resultDiv = dom.byId("resultDiv");
    
            // Attach the onclick event handler to the textButton
            on(dom.byId("textButton"), "click", function(evt){
                // Request the text file
                request.get("../resources/text/psalm_of_life.txt").then(
                    function(response){
                        // Display the text file content
                        resultDiv.innerHTML = "<pre>"+response+"</pre>";
                    },
                    function(error){
                        // Display the error returned
                        resultDiv.innerHTML = "<div class="error">"+error+"<div>";
                    }
                );
            });
        }
    );

    官网地址:http://dojotoolkit.org/documentation/tutorials/1.10/ajax/index.html

  • 相关阅读:
    Hadoop- Cluster Setup
    Hadoop- Cluster Setup
    【网络协议】动态主机配置协议DHCP
    【网络协议】动态主机配置协议DHCP
    数据流(任务并行库 TPL)
    数据流(任务并行库 TPL)
    js数据存储.html
    对象操作(2).html
    对象操作(1).html
    对象forin循环.html
  • 原文地址:https://www.cnblogs.com/tiandi/p/4492348.html
Copyright © 2011-2022 走看看