javascript - Errors with Google Custom Search popular queries -


i've got custom search on website , i'd display popular searches using custom search popular queries option. first off, code google gives in process wrong - kept getting bad requests. this post helped me rebuild correct url, i'm getting syntax error.

when run test, get, uncaught syntaxerror: unexpected token : in console json information comes back.

here's html:

<div id="queries"></div>         <script src="https://cse.google.com/query_renderer.js"></script>         <script src="https://www.google.com/cse/api/userid/cse/cseid/queries/js?view=overall&callback=(new+popularqueryrenderer(document.getelementbyid('queries'))).render"></script> 

the colon throwing error after title, can't figure out why happening.

{ "title" : "mtbos search engine", "popularqueries" : [ ...rest of results array... ] } 

lastly, tried calling json response formatting checker copying , pasting call url , returned handful of html errors. issue query renderer script?

any appreciated.

if @ example on google (you should able see @ bottom of google custom search/statistics , logs page), should see instead of single quotes, google’s example uses encoded double-quotes:

<script src="https://www.google.com/cse/api/userid/cse/cseid/queries/js?view=overall&callback=(new+popularqueryrenderer(document.getelementbyid(%22queries%22))).render"></script> 

i not understand why single quotes not work there, however, have verified me @ least not. if put single quotes there, error saw:

syntaxerror: unexpected token ':'. parse error.

if put percent-encoded quotes there, creates list of popular queries.

it appears single quotes issue, not aren’t encoded use in urls. if replace %22 %27 (encoded single quotes), same “unexpected token” error results.

if there reason wish avoid percent-encoding, legal use single quotes surround attributes, this:

<script src='https://www.google.com/cse/api/userid/cse/cseid/queries/js?view=overall&callback=(new+popularqueryrenderer(document.getelementbyid("queries"))).render'></script> 

according html specs, double quotes legal inside of single quotes, , i’ve verified works on search page.


Comments

Popular posts from this blog

How to provide Authorization & Authentication using Asp.net, C#? -

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

How to use Authorization & Authentication in Asp.net, C#? -