DynamicFBML/MockAJAX

From Facebook Developers Wiki

Jump to: navigation, search

Attributes

  • clickrewriteid - This is the id of the div that will be replaced by the returned data.
  • clickrewriteurl - This is the (non-canvas) url from which it will grab the data.
  • clickrewriteform - This is the form to use when submitting.

Usage examples Sample code, with more details, is available at Mock Ajax page.

Examples
A live demonstration can be found here. (Facebook login required, app login not required) (and it has no explanation, can some be provided please?)

Slightly more explanation can be found in the old documentation.

More discussion found here: http://utexas.facebook.com/topic.php?uid=2205007948&topic=6584

Usage Notes
Make the calls directly to your application, i.e. http://myapp.com/url NOT to http://apps.facebook.com/myapp/url . If you call apps.facebook.com you'll get the element removed, because facebook returns a login page, not valid FBML.

Note: The script echoing the value to be displayed by a mockAJAX call must be on the callback page (as specified in your app settings). Any other page will fail.

One useful tip in debugging this: You can inspect the JS object FBML.mockAjaxResponse. Use the Firebug Firefox extension to access this.

Some of the things contained in it:

  • ok - is a boolean telling whether the mock AJAX call was successful. True means everything went OK. False means something went wrong.
  • error_code - is the HTTP response code if there is a problem, like 404 if not found, etc.
  • error_message - is the text of the error message if there was an error.
  • html - is the rendered HTML that was returned back that will be inserted into the DIV

These only show up if you are the developer of the app:

  • parse_errors - parse errors in turning the FBML into HTML
  • render_errors - errors rendering the FBML into HTML
  • fbml - the raw FBML returned from your URL
  • url - the URL the FBML was fetched from