Google plus-one button on a page that is refreshed with AJAX
Asked Answered
F

2

9

Is anyone aware of some code for Google's plus-one button that will work on a page that is refreshed with AJAX? It was very simple with Facebook, but I can't find any documentaion about this for Google.

Thanks.

Foxhound answered 28/9, 2011 at 13:21 Comment(0)
L
18

I was searching for this too and found this

<!-- 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(); place this code and the button will appear

Leucocytosis answered 2/10, 2011 at 20:25 Comment(2)
Thaks for the reply, but unfortunatly this is not working. I was able to find this code through the button generator, but when I use it the button will not even display.Foxhound
In fact - I take back what I said. I did some more reading and sorted this out, and then realised that I was using gapi.plusone.go(); incorrectly (I was actually using it after the AJAX request, not as part of the request - school boy error). So thanks for posting, this is the answer I was looking for.Foxhound
S
0

If you're trying to render a person badge with ajax rather than a plusone you need a different api call: api.person.go(); https://developers.google.com/+/web/badge/#gapi.*.go

Subrogation answered 14/8, 2014 at 15:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.