When I make an AJAX request in WordPress I do it in two ways, but I'd like to know which one is best.
The two that I know of are:
1º) You put your function in functions, eg:
add_action('wp_ajax_nopriv_my-function','my_function');
add_action('wp_ajax_busca-my-function','my_function');
function my_function(){
//code
}
2nd) You create a file, call it the Wordpress functions through wp-blog-header and make the return.
So, is there any other way? Which one would be the best? I'm developing a news portal, and the idea is to have a timeline like Stack Overflow, where every new news the customer is notified to update.