Your AJAX URL varaible is different in your PHP and your JS. In your JS you refer to ajax_url
:
url: modallist.ajax_url,
But the variable defined in PHP is ajaxurl
:
'ajaxurl' => admin_url('admin-ajax.php') ,
This is why you’re getting the full admin page as a response. Your request is going to the current page because there isn’t a real URL.
Your other problem is that the action for your hooks is incorrect. Your hooks are:
add_action('wp_ajax_nopriv_get-list-post', 'get_list_post');
add_action('wp_ajax_ajax_obter-list-post', 'get_list_post');
First of all, they’re different. They should be the same but one has no_priv
. The second problem is that they don’t match the action name in JS. In JS you’ve set the action to:
action: 'get_list_post',
So your hooks should be:
add_action('wp_ajax_nopriv_get_list_post', 'get_list_post');
add_action('wp_ajax_get_list_post', 'get_list_post');