Frage

i want to load google +1 button only when needed,

<script type="text/javascript" src="https://apis.google.com/js/plusone.js">
  {parsetags: 'explicit'}
</script>

so i was thinking of using jQuery.getScript() to do so like:

$.getScript('https://apis.google.com/js/plusone.js', function(data, textStatus){});

or

$.ajax({
  url: url,
  dataType: "script",
  success: success
});

but how can i pass the parsetags: 'explicit' param ?

War es hilfreich?

Lösung

Well, dont bother, i found a solution:

$.ajax({
  url: "https://apis.google.com/js/plusone.js",
  dataType: "script",
  parameters: { parsetags: "explicit" }, 
  success: function () { gapi.plusone.go();  }
});

Andere Tipps

Set a global variable as follows, then load the g+ script:

window['___gcfg'] = { parsetags: 'explicit' };

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top