[wp-hackers] AJAX in plugins and public pages

scribu scribu at gmail.com
Sun Feb 22 05:35:03 GMT 2009


On Sun, Feb 22, 2009 at 6:14 AM, Casey Bisson <casey.bisson at gmail.com>wrote:

>
> Why not just hook into the init action? The following will give you a
> simple ajax response
>
> function my_function(){
>        @header('Content-Type: text/html; charset=' .
> get_option('blog_charset'));
>
>        $s = sanitize_title( $_GET['my_variable'] );
>        echo $s;
>
>        die; // be sure to die when done
> }
>
> if ( isset( $_GET['my_variable'] ) )
>        add_action( 'init', 'my_function' );
>
>
> --Casey
>
> http://maisonbisson.com/
> http://about.scriblio.net/


I didn't realize it could be so simple. Thanks.

--
http://scribu.net


More information about the wp-hackers mailing list