Which event hook for ajax calls?

Discussion corner for Developers of Serendipity.
Post Reply
gregman
Regular
Posts: 91
Joined: Wed Aug 15, 2007 9:32 pm

Which event hook for ajax calls?

Post by gregman »

Hello,

as I am working on some improvements on the karma plugin, I am wondering which event hook best to be used for ajax calls. At the moment I am referencing to the external-plugin event hook in order to be sure that no unwished content/header ist send with the answer. Would it also be possible to reference to the frontend_configure event hook? Are there any advantages/disadvantages using the one or the other?

Regards
Greg
onli
Regular
Posts: 2828
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: Which event hook for ajax calls?

Post by onli »

Hi
Which url would you use for that? And how to fill the event-data-array properly? external-plugin is the normal way and fitting.
gregman
Regular
Posts: 91
Joined: Wed Aug 15, 2007 9:32 pm

Re: Which event hook for ajax calls?

Post by gregman »

Hi,

and thanks for your response. The url I used is "plugin/karma-ajaxquery". The eventData-Array doesnt need to be filled, because the votes are stored in the database immediately and the servers answer is handled with methdos of the DOM. The problem of using the external-plugin-event is that i have to copy the code of the frontend_configure-event or to put it in an extra function.

Regards
Greg
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Which event hook for ajax calls?

Post by garvinhicking »

Hi!

frontend_configure is also executed before external_plugin is loaded. So you could do your checks there and abort the s9y execution workflow.

"external_plugin" however is better fitting in terms of letting others understand that an external URL is involved, it's simply "cleaner".

I would suggest to capsulate the code in a class method, and call $this->ajax() in the event hook, then you can avoid redundant code...?

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
gregman
Regular
Posts: 91
Joined: Wed Aug 15, 2007 9:32 pm

Re: Which event hook for ajax calls?

Post by gregman »

Hi Garvin,

thx for your advice. I will give it a try.

Greg
gregman
Regular
Posts: 91
Joined: Wed Aug 15, 2007 9:32 pm

Re: Which event hook for ajax calls?

Post by gregman »

Well then,

it took some time but now I think it's done. You can download the ajax improved karma plugin at http://www.studium-auskunft.de/uploads/ ... _karma.zip. Hope it will be of worth! English and german language files are updated as well.

Regards,
Greg

EDIT: Now, I also fixed some minor bugs.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Which event hook for ajax calls?

Post by garvinhicking »

Hi!

Great work! Looks very solid, I just committed it to git! You might want to announce this on a seperate thread so people can test it?

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
gregman
Regular
Posts: 91
Joined: Wed Aug 15, 2007 9:32 pm

Re: Which event hook for ajax calls?

Post by gregman »

Thanx for your appreciation. I'll promote it on a a new thread.

Greg
Post Reply