【问题标题】:Google plus-one button on a page that is refreshed with AJAX使用 AJAX 刷新的页面上的 Google 加一按钮
【发布时间】:2011-09-28 13:21:36
【问题描述】:

是否有人知道 Google 的加一按钮的某些代码可以在使用 AJAX 刷新的页面上运行?使用 Facebook 非常简单,但我无法为 Google 找到任何关于此的文档。

谢谢。

【问题讨论】:

    标签: ajax google-plus google-plus-one


    【解决方案1】:

    我也在找这个,发现了这个

    <!-- Place this tag in your head or just before your close body tag -->
    <script type="text/javascript" src="https://apis.google.com/js/plusone.js">
      {parsetags: 'explicit'}
    </script>
    
    <!-- Place this tag where you want the +1 button to render -->
    <g:plusone></g:plusone> 
    
    <!-- Place this render call where appropriate -->
    <script type="text/javascript">gapi.plusone.go();</script>
    

    gapi.plusone.go(); 放置此代码,按钮就会出现

    【讨论】:

    • 感谢您的回复,但不幸的是,这不起作用。我可以通过按钮生成器找到此代码,但是当我使用它时,按钮甚至不会显示。
    • 事实上——我收回我说过的话。我做了一些阅读并整理出来,然后意识到我错误地使用了gapi.plusone.go();(我实际上是在 AJAX 请求之后使用它,而不是作为请求的一部分 - 男生错误)。所以感谢发帖,这就是我一直在寻找的答案。
    【解决方案2】:

    如果您尝试使用 ajax 而不是 plusone 呈现人员徽章,则需要不同的 api 调用:api.person.go(); https://developers.google.com/+/web/badge/#gapi.*.go

    【讨论】:

      猜你喜欢
      • 2020-07-15
      • 2015-02-13
      • 1970-01-01
      • 2013-12-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-21
      • 1970-01-01
      相关资源
      最近更新 更多