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.
AHAX是一种嵌入式解决方案,允许主题或插件开发人员利用非常简单且精简的方式进行AJAX请求。 p>
The goal of this plugin is to make the process of setting up an AJAX request as simple as possible.
此插件的目标是使设置AJAX请求的过程尽可能简单。 p>
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
此插件将AJAX请求集中在一个“动作”周围。此动作“绑定”到后端的函数(处理程序),并通过自定义JavaScript类方法从前端调用到该动作-如下所示
.
p>
Back-End
后端 h4>
ahax::bind( 'get_random_number', 'generate_number' ); ahax :: bind('get_random_number','generate_number');function generate_number($output) { $max = abs( ( int ) $_POST['max'] );
函数generate_number($ output){$ max = abs((int)$ _POST ['max']);
$output = mt_rand( 0 , ( $max <= 1000 ? $max : 1000 ) );
$ output = mt_rand(0,($ max <= 1000?$ max:1000));
return $output;
返回$ output;
}
} code> pre>
Front-End
前端 h4>
var ahax = new AHAX(); var ahax = new AHAX(); ahax.post( 'get_random_number', { max : 1000 }, function( response ) { jQuery( '#ahax_number' ).html( response ); });
ahax.post('get_random_number',{max:1000},function(response){jQuery('#ahax_number').html(response);});
code> pre>
Website
网站 h4>
http://dan.doezema.com/2011/04/ahax-wordpress-plugin
http://dan.doezema.com/2011/04/ahax-wordpress-plugin p>
Author
作者 h4>
Daniel Doezema
丹尼尔·多兹玛 p>