Ajax functions in buddypress plugins

Building a plugin for Buddypress groups…

I am developing a plugin called Activity plus RLT tabs extension based on a plugin I found in wordpress, it is to add tabs to filter the activity stream in buddypress groups.

At the beginning I was very happy with the plugin that I found but quickly I realized that it has a lot of problems. specially with AJAX.

So, I decided to fix the plugin because even with its problems it was a good start to get what my co-workers and I are looking for. Our objective is build a gallery of images and videos with the videos and images that people upload to the buddypress group activity stream.

I realized that the problem with AJAX request of the plugin was because the events related to the activity updates in the groups are handle using event delegation and the DOM element use by buddypress to attach the event wasn’t present.

Screen Shot 2014-05-16 at 11.07.03 PM

Screen Shot 2014-05-16 at 11.07.38 PM

After sometime, taking a look of the code and studying a bit from resources like:

http://codex.wordpress.org/AJAX_in_Plugins

I knew I must implement my own AJAX handlers to create what we want, so, I started and it was quite interesting. After 3 days I released the first prototype:

Screen Shot 2014-05-16 at 11.14.07 PM

Screen Shot 2014-05-16 at 11.15.22 PM

It is not beautiful yet, but it works.

A new problem to fix in Buddypress …

Well, everything was working, until I got an error related with my AJAX request. I was very confused, but until 1 or 2 hours I found the problem. Here it is:

A malformed JSON response!!!

errorAjaxBuddy

The fact is that it wasn’t my error and I had to report it to buddypress to receive feedback from the genius behind buddypress and fix this problem. I found a solution and now I dont have problems with my AJAX function, but the buddypress AJAX functions still having troubles.

This is the report issue if you want a take a look: https://buddypress.trac.wordpress.org/ticket/5648

Well, I will try to finish my plugin and get it working soon, hopefully it is going to be amazing!!!

[likebtn]

Leave a Reply

Your email address will not be published. Required fields are marked *