亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb

首頁 > 開發 > AJAX > 正文

十分鐘學會 xajax

2024-09-01 08:26:09
字體:
來源:轉載
供稿:網友

譯者按:xajax 最大的特點是他采用了xml response,這樣我們可以用php來布置,處理異步傳送數據之后,網頁內容的更新。而這些操作其它的ajax 框架都是由js來完成的的。xajax 使我們只需要寫一些php函數,就可以實現。

所有學好xajax的關健在于熟練掌握 xajaxresponse 類。

tutorials:learn xajax in 10 minutes

教程:十分鐘學會 xajax

using xajax in a php script

一個使用的xajax的php腳本:

include the xajax class library:

調用xajax類庫:

require_once("xajax.inc.php");

instantiate the xajax object:

實例化xajax對象

$xajax = new xajax();

register the names of the php functions you want to be able to call through xajax:

注冊一個你想用xajax來調用的php函數名(與javascript中的函數名相對應 xajax_myfunction)

$xajax->registerfunction("myfunction");

write the php functions you have registered and use the xajaxresponse object to return xml commands from them:

編寫那個你剛剛已經注冊的php函數,并從中用 xajaxresponse 對象來返回xml指令集

以下為引用的內容:

function myfunction($arg)
{
// do some stuff based on $arg like query data from a database and
// put it into a variable like $newcontent
//對參數$arg做一些諸如:從數據庫中獲取數據后定義給$newcontent 變量的基本操作

// instantiate the xajaxresponse object
//實例化 xajaxresponse 對象
$objresponse = new xajaxresponse();

// add a command to the response to assign the innerhtml attribute of
// the element with id="someelementid" to whatever the new content is
// 在響應實例中添加一個命令,用來將id為someelementid的innerhtml元素屬性
// 變為任何新的內容.
$objresponse->addassign("someelementid","innerhtml", $newcontent);

//return the xml response generated by the xajaxresponse object
//返回由 xajaxresponse 對象所生成的xml 響應
return $objresponse->getxml();
}

before your script sends any output, have xajax handle any requests:

在你腳本傳送出任何東西前,xajax都要處理所有請求

$xajax->processrequests();

between your <head></head> tags, tell xajax to generate the necessary javascript:

在該頁的<head>和</head>標簽之間插入下列代碼,使xajax實例可以自己生成所必需的js

以下為引用的內容:

<?php $xajax->printjavascript(); ?>

call the function from a javascript event or function in your application:

從你程序中的js 事件或函數調用之前你已經注冊過的相對應函數

以下為引用的內容:
<div id="someelementid"></div>
<button onclick="xajax_myfunction(someargument);">
that's it. xajax takes care of most everything else. your biggest task is writing the php functions and returning xajax xml responses from them-- which is made extremely easy by the xajaxresponse class.

只需這些步驟。其他的交由xajax 去處理吧。你最主要的任務只是編寫php中的函數,只要使它們能返回xajax的xml響應就行了,而這步可以用xajaxresponse 類輕松解決。

how do i update my content asynchronously?

如何異步更新我的內容?

perhaps the most unique feature of xajax is the xajaxresponse class. other ajax libraries require you to write your own callback handlers in javascript to process the data returned from an asynchronous request and to update the content. xajax, on the other hand, allows you to easily control your content from php. the xajaxresponse class allows you to create xml instructions to return to your application from your php functions. the xml is parsed by xajax message pump and the instructions tell xajax how to update the content and state of your application. the xajaxresponse class currently offers a number of useful commands, such as assign, which sets the specified attribute of an element in your page; append, which appends data to the end of the specified attribute of an element in your page; prepend, which prepends data to the beginning of the specified attribute of an element in your page; replace, which searches for and replaces data in the specified attribute of an element in your page; script, which runs the supplied javascript code; and alert, which shows an alert box with the supplied message text.

xajax最獨特的長處也許就是 xajaxresponse class了。其它的ajax庫需要你親自寫用js寫回調的句柄,來處理一個異步請求而且得到的數據,并更新其內容。另一方面,xajax只需你簡單的控制好php的內容。然后通過xajaxresponse 類,使在你的php函數中創建xml指令返回給你的程序。xml將被 xajax的信息(pump)解析。其指令告知xajax將如何更新內容和你程序中的位置?,F在xajaxresponse 已經提供了大量并有幫助的指令:http://www.flaspx.com/weblog/blog.php?bid=16 (略...付上詳細的xajaxresponse 類說明)

a single xml response may contain multiple commands, which will be executed in the order they were added to the response. for example, let's say that a user clicks on a button in your application. the onclick event calls the javascript wrapper for a php function. that wrapper sends an asynchronous request to the server through xmlhttprequest where xajax calls the php function. the php function does a database lookup, some data manipulation, or serialization. you use the xajaxresponse class to generate an xajax xml response containing multiple commands to send back to the xajax message pump to be executed:

一個單獨xml響應可以包含多條命令,他們將依據加入響應的順序來被執行。舉個例子吧,讓我們假設一個用戶在你的程序中按下了一個按鈕。這個按下的事件將調用被js封裝好的php函數。這個封包通過 xmlhttprequest 發出了一個異步請求給服務器,讓xajax調用php函數。這個php函數做了一個查詢數據庫,一些數據處理或排序的操作。而你要用 xajaxresponse 類來產出一個 xajax 的xml響應,它包含了多條命令。送給xajax 信息pump來執行:

以下為引用的內容:

$objresponse = new xajaxresponse();

$objresponse->addassign("myinput1","value",$datafromdatabase);
$objresponse->addassign("myinput1","style.color","red");
$objresponse->addappend("mydiv1","innerhtml",$datafromdatabase2);
$objresponse->addprepend("mydiv2","innerhtml",$datafromdatabase3);
$objresponse->addreplace("mydiv3","innerhtml","xajax","<strong>xajax</strong>");
$objresponse->addscript("var x = prompt(/"enter your name/");");

return $objresponse->getxml();
the xajax message pump would parse the xml message and perform the following:

xajax信息pump將會解析下列xml信息,并執行以下操作:

the value of the element with id myinput1 would be assigned to the data in $datafromdatabase.

將變量$datafromdatabase賦值給id為myinput1的value元素。

the color of the text in the element with id myinput1 would be changed to red.

id為myinput1的字體顏色元素將被換成紅色.

the data in $datafromdatabase2 would be appended to the innerhtml of the element with id mydiv1.

$datafromdatabase2,此數據將被追加到id為mydiv1的innerthml元素的結束部位

the data in $datafromdatabase3 would be prepended to the innerhtml of the element with id mydiv2.

$datafromdatabase3,此數據將被添加到id為mydiv2的innerthml元素的開始部位

all occurrences of "xajax" in the innerhtml of the element with id mydiv3 would be replaced with "xajax"; making all of the instances of the word xajax appear bold.

id為mydiv3的innerhtml元素中所有的 "xajax" 將被替換成 "xajax",使所有的xajax以粗體顯示。

a prompt would be displayed asking for the user's name and the value returned from the prompt would be placed into a javascript variable named x.

會有一個輸入框彈出,并詢問用戶姓名。從輸入框取得的變量將轉換成js變量并命名為x。

all of this is implemented on the server side in the php function by forming and returning an xajax xml response.

所有這些組成了php函數在服務器端被執行,然后傳回一個xml響應。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb
亚洲第一页自拍| 国产成人精品日本亚洲专区61| 欧洲精品在线视频| 岛国av一区二区在线在线观看| 中日韩美女免费视频网址在线观看| 粉嫩av一区二区三区免费野| 久久精品久久久久久| 亚洲精品美女久久久| 国产精品老牛影院在线观看| 欧美裸体xxxxx| 国产欧美日韩精品丝袜高跟鞋| 91九色国产社区在线观看| 久久婷婷国产麻豆91天堂| 亚洲电影第1页| 国产精品毛片a∨一区二区三区|国| 成人a在线视频| 自拍视频国产精品| 欧美大片免费观看| 国产欧美亚洲视频| 欧美激情免费在线| 欧美国产视频一区二区| 91地址最新发布| 日韩精品在线观看网站| 欧美午夜美女看片| 亚洲第一免费网站| 亚洲精品国产精品自产a区红杏吧| www.亚洲成人| 色爱精品视频一区| 亚洲一区二区日本| 亚洲精品欧美日韩| 国产一区二区三区在线视频| 在线亚洲欧美视频| 91精品国产亚洲| 懂色aⅴ精品一区二区三区蜜月| 久久精品中文字幕一区| 亚洲摸下面视频| 欧美xxxx做受欧美| 国产欧美日韩免费看aⅴ视频| 2019中文字幕在线免费观看| 久久的精品视频| 综合欧美国产视频二区| 国产视频精品va久久久久久| 国内精品小视频| 国产精品入口尤物| 日本高清不卡的在线| 97精品国产91久久久久久| 国产精品久久999| 亚洲偷熟乱区亚洲香蕉av| 国产精品偷伦一区二区| 国产精品久久久久久久久久久不卡| 日韩在线观看免费网站| 8050国产精品久久久久久| 欧美成人精品不卡视频在线观看| 亚洲高清av在线| 97久久精品视频| 亚洲欧美国产精品va在线观看| 欧美激情一二三| 国产91ⅴ在线精品免费观看| 国内精品久久久久久久久| 欧美日韩国产成人| 国产精品专区一| 日韩免费黄色av| 成人黄色网免费| 久久视频在线免费观看| 久久久久久亚洲精品| 久久久免费av| 久久久久久国产| 亚洲欧洲视频在线| 一区二区福利视频| 欧美日韩成人在线播放| 久久久久久久久中文字幕| 日韩免费高清在线观看| 成人免费在线视频网址| 久久久国产视频91| 萌白酱国产一区二区| 91日本在线视频| 国产精品黄页免费高清在线观看| 久久久久久亚洲精品不卡| 91亚洲午夜在线| 成人有码在线视频| 国产精品久久久久久久久久久不卡| 亚洲一区二区三区乱码aⅴ| 日韩国产欧美精品在线| 久久久天堂国产精品女人| 97精品久久久中文字幕免费| 欧美日韩成人在线播放| 欧美视频二区36p| 国产久一一精品| 亚洲国产私拍精品国模在线观看| 日韩高清电影免费观看完整版| 日韩免费在线看| 国产欧美精品在线| 欧美日韩激情视频8区| 国产精品尤物福利片在线观看| 啪一啪鲁一鲁2019在线视频| 国产小视频91| 成人精品aaaa网站| 亚洲一区二区久久久| 久久精品在线播放| 国产亚洲精品美女| 亚洲女成人图区| 国产精品伦子伦免费视频| 欧美人与性动交a欧美精品| 久久久人成影片一区二区三区| 欧美成人午夜剧场免费观看| 有码中文亚洲精品| 欧美理论电影在线播放| 精品久久久香蕉免费精品视频| 国产一区二区视频在线观看| 韩日精品中文字幕| 91久久精品美女| 日韩中文在线观看| 精品久久国产精品| 色中色综合影院手机版在线观看| 久久久久国产精品免费| 亚洲精品国产精品国自产观看浪潮| 国内久久久精品| 国产精彩精品视频| 日韩精品在线电影| 少妇高潮久久77777| 日韩视频免费看| 日韩一二三在线视频播| 亚洲一区av在线播放| 国产精品视频久久| 性欧美xxxx| 欧美在线视频免费| 日韩a**站在线观看| 国产精品日韩久久久久| 欧美伊久线香蕉线新在线| 亚洲视频在线观看视频| 亚洲人a成www在线影院| 日韩电影网在线| 国内精品美女av在线播放| 精品福利樱桃av导航| 成人黄色免费网站在线观看| 成人动漫网站在线观看| 色婷婷成人综合| 97人人模人人爽人人喊中文字| 最近2019中文字幕第三页视频| 亚洲一级免费视频| 午夜免费日韩视频| 亚洲女人天堂色在线7777| 午夜剧场成人观在线视频免费观看| 亚洲精品国产精品久久清纯直播| 国产精品久久久久久久一区探花| 久久网福利资源网站| 欧美性猛交xxxxx免费看| 国产亚洲欧洲高清| 一区二区三区国产在线观看| 国产精品中文在线| 亚洲欧美成人在线| 国产亚洲欧美日韩美女| 成人精品视频久久久久| 九九九久久久久久| 亚洲毛片在线观看.| 国产日本欧美一区二区三区在线| 欧美在线性视频| 欧美色道久久88综合亚洲精品| 最近2019年手机中文字幕| 7777精品视频| 国产偷国产偷亚洲清高网站| 日韩激情在线视频| 日韩成人黄色av| 在线看欧美日韩|