Sajax is an useful ajax framework to simplify ajax based development for languages like PHP, Ruby etc. Not many realize Sajax can be used equally well from plain old html pages (as in .html or .htm). sajax是一個有用的AJAX框架,以簡化基於Ajax的發展,為語言一樣, PHP中,紅寶石等不是很多,實現sajax可以用同樣從平原歲的HTML網頁(如在。 HTML或與。 htm ) 。 Their website doesn’t mention it anywhere so I can guess it was not one of their use cases.他們的網站上並沒有提及它在任何地方,所以我可以猜測這是不是其中之一,他們使用的案件。 However sajax is based upon ajax which is plain old Javascript.但是sajax是基於AJAX技術,這是平原歲的JavaScript 。 Let’s find out how we can use trusty old sajax to liven up your static pages.讓我們看看我們如何可以使用可靠的舊sajax搞活您的靜態網頁。

To use sajax from html you need to get the javascript code it generates and include it in your html pages.使用sajax從HTML您要得到JavaScript代碼,它產生和它包含在您的HTML頁面。
Sajax doesn’t tell you how you can create a javascript file to include (in your html pages), thereby allowing you to call php (for example) function calls from client side javascript. sajax不告訴您如何,您可以創建一個JavaScript文件,包括(在您的HTML頁) ,從而讓您呼叫的PHP (例如)函數調用從客戶端的JavaScript 。 This can however be remedied with a simple call:這可以,但予以糾正一個簡單的電話:

This generates the required javascript file (change filename to your liking).這生成所需的JavaScript文件(改變文件名,以您的喜好) 。 Include this file in your html pages and you are good to go.包括這個文件在您的HTML網頁,你是好去。 Now you can call your exported php function from javascript.現在,您可以打電話給你的出口PHP函數從JavaScript的。 Remember to append the function names with x_ .記得要附加功能的名稱與x_

How can you use it?你如何能使用它?
Check my檢查我的 Annotated wordPress source code cross-reference註明的WordPress的源代碼交叉參考 site for an example.網站的一個例子。 Check out the sajax based commenting system.簽出sajax為基礎的評論系統。

PS.保安局常任秘書長。 As a side tip you should know sajax_init() function call is not required and can be eliminated with current versions of Sajax.作為一個方提示你應該知道sajax_init ( )函數調用並不需要和可以被淘汰,與當前版本的sajax 。 It does nothing.它什麼都不做。