First I found the demo in google doc:

HTML Code:
<html>
  <head>
    <title>JSON/Atom Custom Search API Example</title>
  </head>
  <body>
    <div id="content"></div>
    <script>
      function hndlr(response) {
          // handle result
      }
    </script>
    <script src="https://www.googleapis.com/customsearch/v1?key=KEY&cx=cx&q=cars&callback=hndlr">
    </script>
  </body>
</html>
And it works fine.

But know I want to trigger the "search process" inside a js file say mySearch.js, so how can I get this done ?

example:

HTML Code:
var XXXLayer = cc.Layer.extend({
    init:function () {
        this._super();
        var theUrl = 'https://www.googleapis.com/customsearch/v1?key=KEY&cx=cx&q=cars&callback=hndlr';

        // what to do here ???????

        return true;
    },
    hndlr:function(response) {
          // handle result
    }
});
Any suggestion would be appreciated thanks