YUI实现跨域交换文件

YUI实现跨域请求js.


<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=GBK">
        <title>Store</title>
        <!-- Dependencies -->
        <script src="yahoo-min.js" >
        </script>
        <script src="get-min.js" >
        </script>
        <script language="JavaScript">
            var timestamp_client;
            var timestamp;
            var timestamp_server;
            var assets_wrapper;
            function $(id) {
                return document.getElementById(id);
            }

            function setMsg(msg) {
                tTime = 100;
                $("Shelf").innerHTML = msg;
            }

            var successHandler4timestamp = function(o) {
                o.purge(); //removes the script node immediately after executing;
                if(timestamp_client!=timestamp_server) {
                    timestamp_client=timestamp_server;
                    try {
                        var objTransaction = YAHOO.util.Get.script("http://localhost/Warehouse/event.js", {
                            onSuccess: successHandler4assets,
                            data: {
                                assets_wrapper: assets_wrapper,
                            }
                        });
                    } catch(e) {
                        alert(e);
                    }
                }
            }
            var successHandler4assets = function(o) {
                o.purge(); //removes the script node immediately after executing;
                // alert(assets_wrapper);
                setMsg(assets_wrapper);
            }
            function sleep(n) {
                var   start=new   Date().getTime();
                while(true)
                    if(new   Date().getTime()-start> n)
                        break;
            }

            function update() {
                try {
                    var timestampTransaction = YAHOO.util.Get.script("http://localhost/Warehouse/timestamp.js", {
                        onSuccess: successHandler4timestamp,
                        data: {
                            timestamp_server: timestamp_server,
                        }
                    });
                } catch(e) {
                    alert(e);
                }
            }

            function init() {
                window.setInterval(update, 500);
            }

        </script>
    </head>
    <body οnlοad="init()">
        <h1>Store</h1>
        <div id="Shelf">
            <h2>Shelf</h2>
    
        </div>
    </body>
</html>


王海良@Chatopera 聊天机器人 机器学习 智能客服
Chatopera 联合创始人 & CEO,运营聊天机器人平台 https://bot.chatopera.com,让聊天机器人上线!2015年开始探索聊天机器人的商业应用,实现基于自然语言交互的流程引擎、语音识别、自然语言理解,2018年出版《智能问答与深度学习》一书。