Skip to content

Instantly share code, notes, and snippets.

@ocean90
Created September 15, 2011 13:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ocean90/1219220 to your computer and use it in GitHub Desktop.
Save ocean90/1219220 to your computer and use it in GitHub Desktop.
Load Google+ button with jQuery AJAX
( function( $ ) {
$( document ).ready( function() {
// Skript wird nur geladen, wenn ein Artikel in der Einzelansicht angezeigt wird.
if ( $( 'body.single' ).length ) {
$.ajax( {
type: 'GET',
url: 'https://apis.google.com/js/plusone.js', // Link zur plusone.js Datei.
timeout: 1000, // Passiert innerhalb von 1000ms nichts, wird der Ladevorgang abgebrochen.
dataType: 'script',
cache: true, // Javascript Datei cachen lassen.
success:
function() { // Bei Erfolg Variable lang auf de setzen.
window.___gcfg = { lang: 'de' };
},
error:
function() { // Bei einem Fehler kann z.B. etwas entfernt werden.
$( '.google' ).parent().hide();
}
} );
};
} );
} )( jQuery );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment