- Note that url must be full, absolute path to file on your server — not a canvas page (apps.facebook…).
- One you should note that there is no “setInnerHtml” call in FBJS for security reasons. If you want to add dynamic HTML you must add it on the server side and pass it using the setInnerFBML call. (Beta. You can now use setInnerXHTML to pass HTML back from Ajax calls. You can also use FBJS_LocalProxy to bypass the Facebook server hop.)
- Don’t pass HTML with
setTextValuebecause it won’t work. - Ajax has an apparent short ~10 second max timeout! –Does anyone have an alternative for queries that may take longer for some users?
- Be aware of silent 5000 byte size limit to JSON replies if JSON is not perfect (use json_encode to avoid this bug) http://bugs.developers.facebook.com/show_bug.cgi?id=363
- Ideally the url will point to a non-static location that has content sent through some form of CGI. In formal language, the url must respond to a request for application/x-www-form-urlencoded content.
- When using JSON and setInnerFBML, the prefix of the FBML parameter has to be ‘fbml_’. The parameter will then be sanitised, and passed on to setInnerFBML.
links demonstrate the Ajax object:<br />
<a href=”#” onclick=”do_ajax(Ajax.JSON); return
false;”>JSON</a><br />
<a href=”#” onclick=”do_ajax(Ajax.RAW); return
false;”>RAW</a><br />
<a href=”#” onclick=”do_ajax(Ajax.FBML); return
false;”>FBML</a><br />
<label><input type=”checkbox” id=”requirelogin”
checked=”checked” /><span>Require
Login?</span></label><br />
<div><span id=”ajax1″></span><span
id=”ajax2″></span></div>
<script><!–
function do_ajax(type) { var ajax = new Ajax(); ajax.responseType =
type; switch (type) { case Ajax.JSON: ajax.ondone = function(data) {
document.getElementById(’ajax1′).setTextValue(data.message + ‘ The
current time is: ‘ + data.time + ‘. ‘);
document.getElementById(’ajax2′).setInnerFBML(data.fbml_test); } break;
case Ajax.FBML: ajax.ondone = function(data) {
document.getElementById(’ajax1′).setInnerFBML(data);
document.getElementById(’ajax2′).setTextValue(”); } break; case
Ajax.RAW: ajax.ondone = function(data) {
document.getElementById(’ajax1′).setTextValue(data);
document.getElementById(’ajax2′).setTextValue(”); } break; }
ajax.requireLogin =
document.getElementById(’requirelogin’).getChecked();
ajax.post(’http://example.com/testajax.php?t=’+type);
}
//–></script>

And then, of course, there is the case of Paul Maurice, late of the Maple Leafs and the current architect of the Carolina Hurricanes’ appearance in the third round of the playoffs.
Entries (RSS)