Update Profile FBML without full page refresh.

Dec 15, 2007 at 4:19 AM

anyone know of any good tutorials/advice on updating a profile box without undergoing a full page-refresh? A mock-ajax type. I've searched for good advice and I suspect it uses fbml such as clickrewriteid, clickrewriteurl and clickrewriteform, but I cannot get solid advice on how to perform it.

Essentially I just want a button that changes text from "Before Dynamic Update" to "After Dynamic Update" within my application's profile box on the user profile page. I can do it easily with a standard setFBML call with a full page refresh, but this is untidy and unprofessional.

Any help greatly appreciated.

Feb 23, 2008 at 4:15 AM
I realize this is a while ago now, but did you solve this problem? If so, how?

Thanks for any insights or suggestions!

Feb 25, 2008 at 10:52 PM
Have you read the FB wiki entry on FBJS / AJAX? http://wiki.developers.facebook.com/index.php/FBJS/Examples/Ajax

I'm not really sure what you mean when you update easily enough with a standard fbml call and a full page reset. In the profile box? What exactly are you doing?

Anyways, assume you have something simple in your profile like a button and a input text box.

setFBML on this:
<h1>My Profile</h1>
<input type="text" id="txtTime" />
<input type="button" onclick="getTime();" value="Get Time" />

<script> <!--

function getTime(type) {
var ajax = new Ajax();
ajax.responseType = FBML;

ajax.ondone = function(data) {

ajax.requireLogin = true;

This assumes that the AJAX page is just response.writing out the current time. Like you could just construct a JSON object and send that back and change the call to ajax.responseType = Ajax.JSON

Code can only run in your profile if someone actually interacts with it, like the button click. I'm not 100% positive that it will call back ok but it should. I've used the FBJS ajax calls on canvas pages fine, but never on profiles. The only reason it wouldn't work is if FB blocks it specifically on the callback.

Hope this helps.