Monday, August 6th, 2007p>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.
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.
- An event handler which fires when an AJAX call returns
- An event handler which fires when an error occurs during an AJAX call
- 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.
- This can be on of Ajax.RAW, Ajax.JSON, or Ajax.FBML.
- The response from your server will be returned to your callback in its original form.
- 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.
- 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.
Posted by Dion Almaer at 1:14 am