Page 1 of 1

Which event hook for ajax calls?

Posted: Sat Mar 19, 2011 1:18 pm
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

Re: Which event hook for ajax calls?

Posted: Sun Mar 20, 2011 12:22 pm
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.

Re: Which event hook for ajax calls?

Posted: Mon Mar 21, 2011 10:15 am
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

Re: Which event hook for ajax calls?

Posted: Mon Mar 21, 2011 11:02 am
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

Re: Which event hook for ajax calls?

Posted: Wed Mar 23, 2011 3:23 pm
by gregman
Hi Garvin,

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

Greg

Re: Which event hook for ajax calls?

Posted: Thu Feb 02, 2012 10:57 pm
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.

Re: Which event hook for ajax calls?

Posted: Wed Feb 08, 2012 3:18 pm
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

Re: Which event hook for ajax calls?

Posted: Fri Feb 10, 2012 2:36 pm
by gregman
Thanx for your appreciation. I'll promote it on a a new thread.

Greg