我尝试用Ajax加载帖子。
functions.php
:
function my_action_callback() {
wp_localize_script(\'jscustom\', \'ajax_custom\', array(
\'ajaxurl\' => admin_url(\'admin-ajax.php\')
));
wp_enqueue_script(\'jscustom\');
}
add_action(\'wp_ajax_my_action\', \'my_action_callback\');
jQuery代码输入
custom.js
:
jQuery(window).load(function() {
var morebutton = jQuery(\'#load-more\'),
archive = morebutton.rel,
deftext = morebutton.text(),
page = 1;
morebutton.click(function(e){
e.preventDefault();
page++;
morebutton.text(ajax_custom.loading);
jQuery.post(ajax_custom.ajaxurl, {action:\'load_more\', page:page, archive:archive}, function(data){...
当我按下“加载更多”按钮时,我得到一个错误:
ReferenceError:未定义ajax\\u自定义
怎么了?