我没有测试它,尝试一些东西像下面使用插件
<?php
/**
* Plugin Name: Blog information
* Plugin URI: http://www.test.com/
* Description: Displays Blog information
* Version: 1.0
* Author: your_name
* Author URI: http://www.test.com/
*/
// Function for handling AJAX requests
function getblog_request_handler() {
// Check that all parameters have been passed
if ((isset($_REQUEST['request']) && ($_REQUEST['request'] == 'getblog_Action'))) {
// Output the response from your call and exit
echo get_bloginfo();
exit();
}
elseif (isset($_REQUEST['request']) && ($_REQUEST['request'] == 'getblog_Action')) {
// Otherwise display an error and exit the call
echo "Error: Unable to display request.";
exit();
}
}
// Add the handler to init()
add_action('init', 'getblog_request_handler');
?>
而且使用JS调用插件功能得到响应,
....
jQuery.ajax({
type : "POST",
url : "index.php",
data : {
request : "getblog_Action"
},
success : function(response) {
alert(response);
//jQuery(".blog_name").html(response);
}
});
....
当过你调用这个AJAX,你将使用ajax获取博客信息。
这听起来不错。只要你在WP环境中,这些功能就应该可以工作...... – elclanrs 2012-03-16 05:08:39
以下是关于@elclanrs的问题,你有没有可能提到Wordpress以外的脚本? – rjz 2012-03-16 05:11:48
该脚本是我正在构建的主题的插件脚本。因此,在页面中,我使用锚链接(使用ajax插件类)调用另一个页面(使用get_header和get_footer ... – user1273237 2012-03-16 05:14:57