WordPress Ajax – looping data into a table

Have you actually added this action through functions.php? This might be of interest for you: https://developer.wordpress.org/reference/hooks/wp_ajax_action/ in your case the php function needs to be added as a hook: add_action(‘wp_ajax_fetch_data’, ‘DisplayInfo’) add_action(‘wp_ajax_nopriv_fetch_data’, ‘DisplayInfo’)