Richer Ajax support for Facebook

Written by on August 6th, 2007 in Ajax News.

Mock Ajax? Huh. That is what I thought when I first read the documentation on building Facebook applications. It was a little sad to see that your choice was either to use the “mock ajax” calls, or to jump into iframe land and do everything on your server, thus not interacting with the Facebook shell.

Well, now JavaScript is going to be a first class citizen with FBJS:

FBJS is Facebook’s solution for developers who want to use Javascript in their Facebook applications. We built FBJS to empower developers with all the functionality they need, and to protect our user’s privacy at the same.

And an Ajax object is available:

FBJS supplies a very powerful AJAX object for developers. It supports retrieving JSON, FBML, or raw text from remote servers. To use it, just instantiate a new Ajax class.

ondone 
An event handler which fires when an AJAX call returns
onerror 
An event handler which fires when an error occurs during an AJAX call
requireLogin 
If you set this to true the AJAX call will require the user to be logged into your application before the AJAX call will go through. The AJAX call will then be made with the regular fb_sig parameters containing the user’s identity. If they refuse to login, the AJAX call will fail.
responseType 
This can be on of Ajax.RAW, Ajax.JSON, or Ajax.FBML.

Ajax.RAW 
The response from your server will be returned to your callback in its original form.
Ajax.JSON 
The response from your server will be parsed as a JSON object and returned to your callback in the form of an object. Properties of your JSON object which are prefixed with “fbml_” will be parsed as individual FBML strings and returned as FBML blocks. These blocks can used on a DOM object with the setInnerFBML method.
Ajax.FBML 
The response from your server will be parsed as FBML and returned as an FBML block. This block can used on a DOM object with the setInnerFBML method.

And one method:

post(url, query) 
Start an AJAX post. url must be a remote address, and query can be either a string or an object which will be automatically converted to a string.

Hopefully this will mean richer Ajax apps on the Facebook platform.

Source: Ajaxian
Original Article: http://feeds.feedburner.com/~r/ajaxian/~3/141103926/richer-ajax-support-for-facebook

Leave a Reply

You must be logged in to post a comment.



Site Navigation