如何使用 FBML 和 FBJS 在页面加载时将 Ajax 内容加载到 div 中?

发布于 2024-09-06 08:26:16 字数 558 浏览 2 评论 0原文

我正在 ASP.NET 2.0 中开发我的第一个 Facebook 应用程序,并做了一件最简单的事情,即在顶部显示一个带有四个超链接的导航,其中每个链接都指向另一个 .aspx 页面。如何在 ASP.NET 2.0 中使用 FBML 来做到这一点?

否则,回到我的问题,在我自己尝试上述事情并失败后,我感到震惊,然后不得不绕过 Ajax 的方式来做到这一点。现在,我使用 Ajax 调用顶部导航中每个超链接的 onclick 事件,并成功加载外部 .aspx 页面(例如 http://apps.facebook.com/brand-is-everything/)。问题是,当用户第一次进入应用程序时,它仅显示 .aspx 页面,该页面具有导航和 Ajax 内容占位符,该占位符被编程为在单击事件上填充内容。

如何在页面加载时将 Ajax 内容加载到 Ajax 内容占位符中,而无需单击事件?

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 navigation 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

今天小雨转甜 2024-09-13 08:26:17

下面是关于如何在 AJAX 调用后将 HTML/FBML 附加到 div 中的示例:

<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>

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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文