tips for successful XFBML rendering
if you are creating a FBConnect application and suffering from unexpected result of XFBML renedeing in your application, here is a cool tip for you. always close yoour tag in <tag></tag> style and not like <tag/>. check out the following example for the differnece –
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">
<head></head>
<script src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php" type="text/javascript"></script>
<body>
<div id="users"></div>
<fb:login-button></fb:login-button>
<script type="text/javascript">
function renderXfbml(uid) {
document.getElementById("users").innerHTML = "<fb:name uid='loggedinuser' useyou='false' /> has sent a gift to <fb:name uid='1009983642' />";
FB.XFBML.Host.parseDomTree();
}
FB.init("5b8d7fcc4d851e29908620757be663d1", "http://sandbox.ofhas.in/fbtest/xd_receiver.htm", {"ifUserConnected" : renderXfbml});
</script>
</body>
</html>
the output looks like the following one, which is no way an expected one – but the XFBML used in the example above is totally valid. it must show something like Hasin Hayder has sent a gift to Rajeeb Khan
Now check out the revised XFBML block in the following example.
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">
<head></head>
<script src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php" type="text/javascript"></script>
<body>
<div id="users"></div>
<fb:login-button></fb:login-button>
<script type="text/javascript">
function renderXfbml(uid) {
document.getElementById("users").innerHTML = "<fb:name uid='loggedinuser' useyou='false'></fb:name> has sent a gift to <fb:name uid='1009983642'></fb:name>";
FB.XFBML.Host.parseDomTree();
}
FB.init("5b8d7fcc4d851e29908620757be663d1", "http://sandbox.ofhas.in/fbtest/xd_receiver.htm", {"ifUserConnected" : renderXfbml});
</script>
</body>
</html>
and the output produced by the code above is perfect!
hope you will take care of this issue and prevent yourself from stumbling. happy FBConnecting








