Created
September 15, 2011 13:29
-
-
Save ocean90/1219220 to your computer and use it in GitHub Desktop.
Load Google+ button with jQuery AJAX
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
( 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