Szymon
Szymon

Reputation: 1290

Google Plus button load by ajax

I've got problem with my website "http://szymondziewonski.com/" , I want to load google plus button with

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

And then, put this script in place which is loaded.

 <script type="text/javascript">gapi.plusone.go(".googlePlusHomePage .special");</script>

It works good mostly someitimes i get error in developers tool, console.

Uncaught TypeError: Cannot read property 'src' of null

So that error is my first problem problem

And second problem is wc3 validate

http://validator.w3.org/check?uri=http%3A%2F%2Fszymondziewonski.com%2F&charset=%28detect+automatically%29&doctype=Inline&ss=1&group=0&user-agent=W3C_Validator%2F1.3+http%3A%2F%2Fvalidator.w3.org%2Fservices

The text content of element script was not in the required format: Expected space, tab, newline, or slash but found { instead.

Syntax of script documentation: Zero or more code comments, each of which is either a single-line comment starting with "//" or a multi-line comment starting with "/" and ending with "/". The content must also meet the constraints of the script microsyntax. For further details, see Inline documentation for external scripts

So, some1 know how to work around that? only with google button there is so much problems. Please help

Upvotes: 1

Views: 470

Answers (1)

abraham
abraham

Reputation: 47833

You have a ; at the end of your parsetags line. That should be removed to look like this.

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

I have not tested it but you might be able to set parsetags to explicit like this and avoid the validation error:

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

Upvotes: 1

Related Questions