wordpress ajax返回0作为响应,用die()检查;和wp_die();但仍然得到0作为回应。
当同时使用die()和wp_die()时,结果为0。任何人都可以提供帮助。
jQuery(document).ready(function(){
jQuery('#profile_form').on("submit", function(e){
//console.log("here");
var User_ids = <?php echo $user_ID ?>;
//console.log(User_ids);
jQuery.ajax({
type: "post",
url: "<?php echo admin_url( 'admin-ajax.php' ); ?>",
data: {
action: "get_percentage",
User_ids: User_ids
},
success : function(data) {
console.log(data);
}
});
});
});
add_action("wp_ajax_get_percentage", "get_percentage");
add_action("wp_ajax_nopriv_get_percentage", "get_percentage");
function get_percentage(){
$user_ID = $_REQUEST['User_ids'];
echo $user;
wp_die();
}