Apr 19

分析sajax 不指定

bkkkd , 13:14 , 开发应用 , 评论(4) , 引用(0) , 阅读(20933) , Via 本站原创 | |

我选择了其中更新服务器时间的那个例子来讲一下吧.
example_date.php

<?
require("Sajax.php");

// Leonardo Lorieri
// My first SAJAX implementention, few lines of inspiration
// A good way to understand SAJAX programming
//
// Work Flow:
// 1- starting by the <body onload="get_date()">
// 2- loading the server's date from the php function,
//      calling the javascript function to show it.
// 3- scheduling another load to the next second
//
// Disclaimer: Hey! I dont speak english
// Under (put your choice here) license

function show_now() {
  //return server date
  return date("l dS of F Y h:i:s A");
}

//starting SAJAX stuff
$sajax_request_type = "GET";
sajax_init();
sajax_export("show_now");
sajax_handle_client_request();
?>
<html>
<head>
        <title>Show Server's Date</title>
        <script>
        <?
        sajax_show_javascript();
        ?>
        function show_me(date_server) {
                document.getElementById("date_div").innerHTML = date_server;
        }

        function get_date() {

                //put the return of php's show_now func
                //to the javascript show_me func as a parameter
                x_show_now(show_me);

                //do it every 1 second
                setTimeout("get_date()", 1000);
        }
        </script>

</head>
<body  onload="get_date();">
Server date: <div id="date_div">(loading...)</div>
</body>
</html>

内文分页: [1] [2] [3] [4] [5] [6] [7]
bvjjk Homepage
November 3, 2007 23:46
这是一条隐藏评论或留言。您需要以合适的身份登入后才能看到。
bhui Homepage
November 3, 2007 23:46
这是一条隐藏评论或留言。您需要以合适的身份登入后才能看到。
dgj Homepage
November 3, 2007 23:45
这是一条隐藏评论或留言。您需要以合适的身份登入后才能看到。
lee Homepage
April 20, 2007 22:48
这是一条隐藏评论或留言。您需要以合适的身份登入后才能看到。
bkkkd 回复于 April 21, 2007 01:06
确实烦
所以都系用别人写好咖。然后自己修改
分页: 1/1 第一页 1 最后页
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]