[wp-hackers] ajax and $wpdb

Jennifer Hodgdon yahgrp at poplarware.com
Wed Jul 29 14:32:27 UTC 2009


scribu wrote:
> On Wed, Jul 29, 2009 at 1:41 PM, Adam Taylor <adamjctaylor at gmail.com> wrote:
> 
>> Secondly: is this the best way of doing this? I can't find any tutorials or
>> documents about writing an ajaxy plugin for wordpress that interacts with
>> the database.
> 
> 
> Definetly not the best way. I would send you to this page, but it's
> outdated, unfortunately: http://codex.wordpress.org/AJAX_in_Plugins
> 
> Basically, instead of calling a script directly, you should do this:
> 
> For logged-in users:
> 
> add_action('wp_ajax_my_action', 'my_ajax_handler');
> 
> For the public:
> 
> add_action('wp_ajax_nopriv_my_action', 'my_ajax_handler');

When did this come in to WordPress? That Codex page was written in an 
era when you couldn't do AJAX in a standardized way outside of the 
admin screens.

     --Jennifer

-- 
Jennifer Hodgdon * Poplar ProductivityWare
www.poplarware.com
Drupal, WordPress, and custom Web programming



More information about the wp-hackers mailing list