[wp-hackers] Talking to Ajax

Kevin Stover kstover at gmail.com
Sun Apr 1 03:43:01 UTC 2012


Hey Dino,

I use ajax quite a bit in many plugins. One of the things that I noticed is
you have closed-**postboxes in the first part of your add_action, and
closed_postboxes in your second half. Make sure that your ajax request uses
the right one. I've done silly things like that before. Secondly, make sure
that you put a "die();" at the end of your called php function
closed_postboxes(){}.

Hope that helps,

Kevin

On Sat, Mar 31, 2012 at 3:54 AM, Rafael Ehlers <rafaehlers at gmail.com> wrote:

> This screencast talks about the exactly issue your on:
> http://pippinsplugins.com/plugin-thoughts-episode-4-learn-how-core-does-it/
>
> ,please watch!
>
> On Fri, Mar 30, 2012 at 11:44 PM, Dino Termini <dino at duechiacchiere.it
> >wrote:
>
> > Hello list,
> >
> > I am developing a plugin that displays a bunch of meta boxes. I'm trying
> > to do something when the 'Show on screen' checkbox for the corresponding
> > meta box is (un)selected. So I added
> >
> > add_action('wp_ajax_closed-**postboxes',  'closed_postboxes');
> >
> > and
> >
> > function closed_postboxes(){
> >        echo 'yeah';
> > }
> >
> > to test it. But according to Firebug, admin-ajax.php returns -1, and the
> > hook is not executed. What am I missing? I found this page
> >
> > http://codex.wordpress.org/**AJAX_in_Plugins<
> http://codex.wordpress.org/AJAX_in_Plugins>
> >
> > Can you please point me in the right direction?
> >
> > Cheers,
> > Dino.
> > ______________________________**_________________
> > wp-hackers mailing list
> > wp-hackers at lists.automattic.**com <wp-hackers at lists.automattic.com>
> > http://lists.automattic.com/**mailman/listinfo/wp-hackers<
> http://lists.automattic.com/mailman/listinfo/wp-hackers>
> >
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list