Apr
19
sajax_show_javascript()只是把 sajax_get_javascript()的字符串输出。所以我们来看一下sajax_get_javascript有什么内容
function sajax_get_javascript()
{
global $sajax_js_has_been_shown;//是否已经展示了基本的js程序
global $sajax_export_list;//可调用的php函数名数组
$html = "";
if (! $sajax_js_has_been_shown) {
$html .= sajax_get_common_js();//生成基本的js程序
$sajax_js_has_been_shown = 1;
}
foreach ($sajax_export_list as $func) {
$html .= sajax_get_one_stub($func);//生成执行操作的函数,函数名为 x_{php函数名}
}
return $html;
}
现在再来看一下sajax整体流程
先定义服务器端的sajax相关数据
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");
所以都系用别人写好咖。然后自己修改