jquery - How to add value to google custom search with javascript -


i want add json data gotten database google custom search javascript file cant because jquery method of adding value input box fails when comes google custom search.

any please

here code:

(function() {     var cx = '005172588709921972888:fsuibenly4m';     var gcse = document.createelement('script');     gcse.type = 'text/javascript';     gcse.async = true;     gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +         '//cse.google.com/cse.js?cx=' + cx;     var s = document.getelementsbytagname('script')[0];     s.parentnode.insertbefore(gcse, s); //checks if id empty      if ( $('#gsc-i-id1').is(':empty')  ) {        console.log('search empty'); //if empty add code        $(".gsc-input").val("dolly duck");      }      else {         console.log('search not empty');    };   })(); //the above code fails because kept on seeing "search not empty" in log // tried 1 , fails again   $("#gsc-i-id1").val("dolly duck"); 

`

any please.

i able solve problem after checking out google's developers ref page cse.google.com page. used ?q=lady+gaga query url particular search , using ajax worked magic.

http://localhost/ailab/searchapi.php?q=lady+gaga did trick


Comments