title: hi how can i fetch json from a url using javascript
body: <p>I am trying to build a browser extension with key functionality including fetching a text input from html pages and concat it with a URL and fetch json from that concated URL.</p>
  
  <p>I want to know how to fetch json from a URL to a variable using JavaScript.</p>
  
  <p>This is the html script to grab the user inserted text.</p>
  
  <pre><code>&lt;html&gt;
  &lt;body&gt;
  &lt;input type="text" id="search" name="Name" maxlength="10" class="searchField" autocomplete="off" title="" &gt;&lt;br&gt;
    &lt;/p&gt;
  &lt;/form&gt;
  &lt;p align="center"&gt;
  &lt;button type="button" id="srchbutton" style="background-color:Thistle;margin-left:auto;margin-right:auto;display:block;margin-top:22%;margin-bottom:%"&gt; Search&lt;/button&gt;
  &lt;/p&gt;
  &lt;script language="javascript" type="text/javascript" src="thanq.js"&gt;
      var button= document.getElementById('srchbutton');
      button.onclick= linkprocess();
      console.log("hi there");
  &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>and this is the JavaScript in which I am trying to access the json from URL.</p>
  
  <pre><code>var oldlink='URL';
  var newlink;
  function linkprocess(links){
      var text= document.getElementById('search');
     newlink=oldlink+text;
     GetJson(newlink);
     console.log(newlink);
  }
  </code></pre>