How to load Ajax contents into a div on page load using FBML and FBJS?
I'm developing my first Facebook application in ASP.NET 2.0 and doing a simplest thing, that is, to show a navigation on top with four hyperlinks where each link targets to another .aspx
page. How can I do this using FBML in ASP.NET 2.0?
Otherwise coming to my question, where I'm struck after trying above thing at myself and failed then had to go around the Ajax way of doing this. Now I'm using Ajax call over the onclick
event of each hyperlink from top navigati开发者_Go百科on and it's succesfully loading external .aspx
pages (for example, http://apps.facebook.com/brand-is-everything/). The problem is when user comes on the application on first time, it only shows the .aspx
page which has a navigation and a Ajax content place holder which is programmed to be filled with contents on click event.
How to load Ajax contents into the Ajax content place holder on page load without a click event?
Here an example on how to append HTML/FBML into a div after an AJAX call:
<script type="text/javascript">
var ajax = new Ajax();
ajax.responseType = Ajax.FBML;
ajax.ondone = function(response) {
document.getElementById('myDiv').setInnerFBML(response);
}
var postUrl = '<?php echo CALLBACK_URL ?>';
postUrl += '/services/ajax.php?action=get_content_to_load_into_div';
ajax.post(postUrl);
</script>
<div id="myDiv"></div>
精彩评论