I exploit an ajax known as to get all posts of a customized publish kind and different standards.
I want to get the response of my ajax known as and use it in a template php file. So my query is : how can I cross the info from response ajax to template php file ?
Right here my code js :
operate getPlayers($post_type) {
$.ajax({
kind: "GET",
url: ajaxurl,
information: {
motion: display_players_list',
post_type: $post_type.information('kind'),
},
success: operate(information){
// want to cross the info to my template php file
},
});
}
That is my operate display_players_list with a chunk of code (right here in feedback) the place I attempt to do that.
add_action('wp_ajax_display_players_list', 'display_players_list');
add_action('wp_ajax_nopriv_display_players_list', 'display_players_list');
operate display_players_list(){
$get_current_user = wp_get_current_user();
$documents_type = $_GET['post_type'];
// gamers
$gamers = get_players($post_type);
/*
$args = [
'total_players' => $players->found_posts,
'total_pages' => $players->max_num_pages,
];
?><part><?php
get_template_part('template/players-list', null, $args);
?></part><?php
exit();
*/
wp_send_json($array_data);
}
The get_players operate is an easy WP_QUERY.
Thanks for assist