[WordPress] 外掛分享: AHAX

首頁外掛目錄 › AHAX
全新外掛
安裝啟用
尚無評分
5453 天前
最後更新
問題解決
WordPress 2.8+ v1.0 上架:2011-04-14

內容簡介

AHAX 是一個即插即用的解決方案,允許主題或外掛程式開發人員利用簡單而精簡的方式來進行 AJAX 請求。

此外掛程式的目標是讓建立 AJAX 請求的流程盡可能簡單。

此外掛程式圍繞著「動作(action)」來進行 AJAX 請求。該動作「綁定(bind)」到後端的一個函式(處理程序),並透過自訂的 JavaScript 類別方法從前端呼叫該函式。

後端
ahax::bind( 'get_random_number', 'generate_number' ); function generate_number($output) { $max = abs( ( int ) $_POST['max'] ); $output = mt_rand( 0 , ( $max <= 1000 ? $max : 1000 ) ); return $output; }
前端
var ahax = new AHAX(); ahax.post( 'get_random_number', { max : 1000 }, function( response ) { jQuery( '#ahax_number' ).html( response ); });
網站

http://dan.doezema.com/2011/04/ahax-wordpress-plugin

作者

Daniel Doezema

外掛標籤

開發者團隊

⬇ 下載最新版 (v1.0) 或搜尋安裝

① 下載 ZIP → 後台「外掛 › 安裝外掛 › 上傳外掛」
② 後台搜尋「AHAX」→ 直接安裝(推薦)
📦 歷史版本下載

原文外掛簡介

AHAX is a drop-in solution that allows theme or plug-in developers to take advantage of a very simple and streamlined way of making AJAX requests.
The goal of this plugin is to make the process of setting up an AJAX request as simple as possible.
This plugin centers AJAX requests around an “action.” This action is “bound” to a function (handler) on the back-end and called to from front-end via a custom JavaScript class method — this process is demonstrated below.
Back-End
ahax::bind( 'get_random_number', 'generate_number' ); function generate_number($output) { $max = abs( ( int ) $_POST['max'] ); $output = mt_rand( 0 , ( $max <= 1000 ? $max : 1000 ) ); return $output; } Front-End var ahax = new AHAX(); ahax.post( 'get_random_number', { max : 1000 }, function( response ) { jQuery( '#ahax_number' ).html( response ); }); Website http://dan.doezema.com/2011/04/ahax-wordpress-plugin Author Daniel Doezema

延伸相關外掛

文章
Filter
Apply Filters
Mastodon