title: How an I extract the JSON data from my Google Custom Search API AJAX call?
body: <p>I'll try and keep it simple and quick.</p>
  
  <p>I am using Google's custom search api to search my website. I use a very basic AJAX call to post a search query.</p>
  
  <pre><code>       var search_term = 'mysite.com'; 
         var xhttp = new XMLHttpRequest();
         xhttp.onreadystatechange = function() {
          if (this.readyState == 4 &amp;&amp; this.status == 200) {
            var response = this.responseText;
            console.log(response);
          };
        };
        xhttp.open("GET", search_term, true);
        xhttp.send();
  </code></pre>
  
  <p>It works as expected. I <code>console.log</code> the <code>this.responseText</code>. The syntax returns something like the below(I shortened it ALOT to make the question easier to read).</p>
  
  <pre><code>// API callback
  hndlr({
   "kind": "customsearch#search",
   "url": {
    "type": "application/json"
  },
  "queries": {
    "request": [
     {
      "title": "Google Custom Search - site:www.mysite.com.au gallery",
      "totalResults": "150",
      "searchTerms": "site:www.mysite.com.au gallery",
      "count": 10,
      "startIndex": 1,
      "inputEncoding": "utf8",
      "outputEncoding": "utf8",
      "safe": "off",
      "cx": "006655164624831528:nz6utbz01b0"
     }
    ]
  }
  });
  </code></pre>
  
  <p>The syntax looks like a function, I would like to extract the inner JSON object and use that data. I have tried to Google this, but no luck, probably because I don't know what to search for exactly.
  How can I do this? </p>
  
  <p>Your help is very much appreciated.</p>
  
  <p>Thanks All,</p>
  
  <p>Moe</p>