• 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

  • 相关阅读:
    Linux下安装FTP服务(Ubuntu)
    Ubuntu下无法使用Secure_CRT连接服务器
    Mysql 锁机制
    PHP提取HTML代码中img标签下src属性
    Mysql 隐式转换
    PHPExcel在TP下使用
    ThinkPHP同时操作多个数据库
    PHP 时间相关操作
    ThinkPHP输入验证和I方法使用
    ThinkPHP模板内使用U方法
  • 原文地址:https://www.cnblogs.com/tiandi/p/4492348.html
Copyright © 2020-2023  润新知