我是jQuery Ajax的初学者,所以请耐心听我说。我的Ajax响应似乎没有加载,但我的更改正在保存。但是在管理ajax上给了我这个错误。php“call\\u user\\u func()期望参数1是有效的回调,未找到函数“\\u update\\u post\\u teru count”或无效的函数名”这是我的函数,你能指出我做错了什么吗?
add_action( \'wp_ajax_nopriv_save_sort\', \'ccmanz_save_reorder\' );
add_action(\'wp_ajax_save_sort\',\'ccmanz_save_reorder\');
function ccmanz_save_reorder() { //checking
//verify user intent
check_ajax_referer( \'wp-job-order\', \'security\' ); // this comes from wp_localize_script() in hrm-jobs.php
//capability check to ensure use caps
if ( ! current_user_can( \'manage_options\' ) ) {
wp_die( __( \'You do not have permission to access this page.\' ) );
}
$order = explode( \',\', $_POST[\'order\'] );
$counter = 0;
foreach ( $order as $item_id ) {
$post = array(
\'ID\' => (int) $item_id,
\'menu_order\' => $counter,
);
wp_update_post( $post );
$counter ++;
}
wp_send_json_success(\'POST SAVED\');
}
我的AJAX调用
jQuery(document).ready(function($) {
sortList = $( \'ul#custom-type-list\' ); //store
var animation = $ ( \'#loading-animation\' );
var pageTitle = $ ( \'div h2\');
sortList.sortable({
update: function ( event, ui) {
animation.show();
$.ajax({
url: ajaxurl, // ajaxurl is defined by WordPress and points to /wp-admin/admin-ajax.php
type: \'POST\',
async: true,
cache: false,
dataType: \'json\',
data:{
action: \'save_sort\', // Tell WordPress how to handle this ajax request
order: sortList.sortable( \'toArray\' ).toString(), // Passes ID\'s of list items in 1,3,2 format
security: WP_JOB_LISTING.security
},
success: function( response ) {
animation.hide();
$(\'div.updated\').remove();
if( true === response.success ) {
console.log(sortList.sortable( \'toArray\' ));
pageTitle.after(
\'<div id="messsage" class="updated"><p>\' + WP_JOB_LISTING.success + \'</p></div>\'
);
} else {
$(\'div.error\').remove();
pageTitle.after( \'<div id="messsage" class="error"><p>\' + WP_JOB_LISTING.failure + \'</div>\' );
}
},
error: function ( error ) {
$( \'div.error\' ).remove();
animation.hide();
//pageTitle.after( \'<div id="messsage" class="error"><p>\' + WP_JOB_LISTING.failure + \'</div>\' );
}
});
}//update
}); //sortable
});//jquery