fb:serverfbml 块内的 javascript 验证

发布于 2024-09-29 14:55:50 字数 603 浏览 0 评论 0原文

我正在尝试验证来自我嵌入的多好友选择器的输入,如下所示:

<fb:serverFbml>
     <script type="text/fbml">
        <form action="http://example.com/testSubmit.php" method="POST" onsubmit="return validate(this);">
            <fb:multi-friend-input name="hidden"/>
            <input type="submit" value="Submit"/>
        </form>
    </script>
</fb:serverFbml>

正如预期的那样,当在 iframe 内呈现时, onsubmit 函数会以我的 appid 开头。我假设我需要将我的 javascript 嵌入到 iframe 中的某个位置,以便我对 validate() 函数的定义也可以在我的 appid 前面加上。

然而,我并没有这样做的运气。我尝试过多种方式将其嵌入 js,但没有成功。

谢谢!

I am trying validate input from a multi-friend-selector that I have embedded like so:

<fb:serverFbml>
     <script type="text/fbml">
        <form action="http://example.com/testSubmit.php" method="POST" onsubmit="return validate(this);">
            <fb:multi-friend-input name="hidden"/>
            <input type="submit" value="Submit"/>
        </form>
    </script>
</fb:serverFbml>

As expected, when rendered inside the iframe, the onsubmit function is prepended with my appid. I am assuming that I will need to embed my javascript somewhere within the iframe, so that my definition of the validate() function can be prepended with my appid as well.

However, I have not had any luck doing so. I have tried embedding it the js a number of ways with no luck.

Thanks!

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

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

发布评论

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

评论(2

人│生佛魔见 2024-10-06 14:55:51

据我了解,您有 FBML 画布应用程序。

在这种情况下,您不需要 fb:serverFbml 包装器。如果仍然不起作用,请尝试按照此处所述添加事件侦听器:

document.getElementById('my_form').addEventListener('submit',validate);

As I understand you have FBML canvas application.

In this case you don't need fb:serverFbml wrapper. If it still doesn't work try adding event listeners as described here:

document.getElementById('my_form').addEventListener('submit',validate);
爱情眠于流年 2024-10-06 14:55:51

由于我需要此页面在 Facebook 内部以及 Facebook 外部呈现,并且我希望具有灵活性,因此我相信对我来说最好的选择是仅使用 js graph api 和 jquery 自动完成小部件。看起来不需要很多额外的工作,并且会给我带来更多的控制权。

Since I need this page to render inside of fb as well as outside of fb and I would like flexibility, I believe that the best option for me will be to just use the js graph api and the jquery autocomplete widget. Does not seem like a lot of extra work, and will provide a lot more control on my end.

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