Data Objects: Using AJAX Functions

Data Objects: Using AJAX Functions

About Ajax Data

BB Website Plugins can retreive data from the Beat Brokerz database in real time (on demand). This data can be used to populate content on the page, or for use as input to your custom processing script. It is retreived using a technology called 'ajax'.

A basic example would be when the beat changes on an mp3 player. If the 'ajax' feature is turned on (see below), then your 'bbmp3_songchange' event processing function will receive a data object as the third argument. This data object contains specific information about the new beat that's playing (such as title, description, licensing, buy now, etc). You can then use this information to update or change content on the page in real time.

How It Works

Turn It On:
First you have to turn the feature on in your processing script. Here is an example on how to do that.

<script type="text/javascript">

  $.bbmp3({
    ajax: true,   /* turns ajax feature on */
  });

</script>

Ajax enabled events:
Currently, the following events receive the optional data object as an argument.

bbmp3_songchange : (playerID, songID [,data])
Note: only the 'render' and 'after' hooks receive the data object for this event.

Object Properties:

  • sellerid : (Integer = Beat Brokerz Seller ID)
  • rating : (Float = Number between 1 and 5 indicating rating)
  • image : (HTML = Complete html img tag for beat graphic)
  • title : (String = Title of beat)
  • producer : (String = Name of producer)
  • description : (String = Description of beat)
  • licensing : (HTML = Complete html markup for licensing options)
  • cartform : (HTML = Complete html markup for add to cart form)

How to use the data object in the 'bbmp3_songchange' event:

<script type="text/javascript">

  $.appflow.bind('bbmp3_songchange','render',function(playerId, beatid, data) {
    // fill elements on the page
    $('.bbmp3-producer').html(data.producer);
    $('.bbmp3-title').html(data.title);
    $('.bbmp3-description').html(data.description);
    $('.bbmp3-rating').html(data.rating);
    $('.bbmp3-image').html(data.image);
    $('.bbmp3-licensing').html(data.licensing);
    $('.bbmp3-cartform').html(data.cartform);
    // the following line adds the fully qualified domain name to the form submit action
    $('.bbmp3-cartform form').attr('action','http://www.rapbeatbrokerz.com' + $('.bbmp3-cartform form').attr('action'));
  });

</script>