Mobile app version of vmapp.org
Login or Join
YK1175434

: Google Custom Search: Uncaught TypeError: google.search.Search.apiary15400 is not a function On my site I get the error : Uncaught TypeError: google.search.Search.apiary15400 is not a function

@YK1175434

Posted in: #GoogleCustomSearch

On my site I get the error :


Uncaught TypeError: google.search.Search.apiary15400 is not a function


where the number changes on each page refresh.

I've already checked here: productforums.google.com/forum/#!topic/customsearch/CYN9lFK46hk, but did not find any double cse references in my own code.

Also, the ads that are being shown on the result page are somehow lightly grayed out.

I tried adding the script code to the head of the googlesearch.aspx page and the cse tag in the body, but that results in the same error.

How I inject the code:

in head:

<script type="text/javascript">
(function () {
var cx = '014868809914487598599:qtooouruo1q';
var gcse = document.createElement('script');
gcse.type = 'text/javascript'; gcse.async = true;
gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//www.google.com/cse/cse.js?cx=' + cx;
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(gcse, s);
})();

</script>


in body:

<gcse:searchresults-only></gcse:searchresults-only>


`

Why is this happening?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @YK1175434

1 Comments

Sorted by latest first Latest Oldest Best

 

@Miguel251

You're loading the script twice, causing the function to run twice and produce this error. An example line that is doubled up:

<script type="text/javascript" async="" src="https://www.google.com/cse/cse.js?cx=014868809914487598599:qtooouruo1q"></script>


It's not the only line that's doubled - perhaps check your code for duplicates. Or if it's being injected check your document write calls to see if they've been doubled up.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme