[wp-hackers] ajax to call function in theme

Michael Pretty mpretty at voceconnect.com
Fri Dec 11 16:57:22 UTC 2009


I had a similar discussion on trac 
(http://core.trac.wordpress.org/ticket/11062).  I think before we work 
on updating the codex, we should come up with a recommended solution for 
handling ajax requests from the front end.  The problem with always 
using admin-ajax is that some sites have the admin in a different domain 
and or have the admin htaccess protected.  Not all users know how to 
make exceptions in the htaccess file to allow the ajax to work. 

Davit Barbakadze wrote:
> There's still some inconsistency. Tutorial says: "Note: In WP 2.8, if
> a user is not logged in ('wp_ajax_nopriv_my_action'), then GET
> requests are ignored (and return -1). This bug was fixed in WP 2.9."
>
> It probably means that for every wordpress with version less then 2.9
> wp_ajax_nopriv_my_action hook doesn't work, right for not logged in
> users? And then it goes again - next section: "Ajax on the
> Viewer-Facing Side ( WordPress 2.6 , 2.7, 2.8 )" and:
> "add_action('wp_ajax_nopriv_my_special_action',
> 'my_action_callback');". At the same time Codex says that: "We need to
> send our request to a plugin PHP file. This should be the main plugin
> PHP file. In case you want it to be a separate PHP file, bare in mind
> that you won't be able to access the Wordpress global variables, e.g.
> $wpdb, since separate files have absolutely no visibility to any part
> of WordPress at all."
>
> I think having all that together, no new comer will be able to figure
> out howto write an ajax call for not logged-in users for WP version
> less then 2.9 (current stable release that is).
>
> On Tue, Nov 17, 2009 at 8:40 PM, nunomorgadinho
> <nuno.morgadinho at gmail.com> wrote:
>   
>> I've also updated this in the Codex example that uses Sack. Took me a while
>> to figure this so maybe it will help others now.
>>
>>
>> scribu wrote:
>>     
>>> Finally updated the Codex example, using jQuery.
>>>
>>> --
>>> http://scribu.net
>>> _______________________________________________
>>> wp-hackers mailing list
>>> wp-hackers at lists.automattic.com
>>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>>
>>>
>>>       
>> --
>> View this message in context: http://old.nabble.com/ajax-to-call-function-in-theme-tp26116790p26393151.html
>> Sent from the Wordpress Hackers mailing list archive at Nabble.com.
>>
>> _______________________________________________
>> 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