title: Javascript function (with variable information in URL) for a simple GET request
body: <p>The situation is as follows:</p>
  <ol>
  <li>A webpage with two inputs; <code>input_1</code> and <code>input_2</code></li>
  <li><code>input_1</code> is a code to be entered by the user</li>
  <li><code>input_2</code> is more like a token string, pre-filled or to be filled by user</li>
  <li>The URL format for the <code>GET</code> request is like this: <code>https://www.apiserver.com/api/v1/static_param_1/input_1/tokens/redeem?token=input_2</code></li>
  </ol>
  <p>The webpage has a form, which includes a button with an element_id of <code>button_1</code>, two text elements with element id's <code>elem_input_1</code> and <code>elem_input_2</code>.</p>
  <p>I need to use javascript to create the GET request which gets fired when the user has input the values and clicked the button.</p>
  <p>I tried the following so far.  Any help is highly appreciated:</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var button = document.getElementById('button_1');
  
  function executeGetReq() { 
    var input_1 = document.getElementById('elem_input_1').value;
    var input_2 = document.getElementById('elem_input_2').value;
  
    var url = "https://www.apiserver.com/api/v1/static_param_1/" + input_1 + "/tokens/redeem"
  
    var data = {
      token: input_2,
    };
    $.get(url, data, function (result) {
      if (result == 'ok')
        alert('Success!');
      else
        alert('Failure');
    });
  }
  
  button.onclick = executeGetReq;</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;input id="elem_input_1" value="input_1"/&gt;
  &lt;input id="elem_input_2" value="input_2"/&gt;
  &lt;button id="button_1"&gt;Go&lt;/button&gt;</code></pre>
  </div>
  </div>
  </p>
  <p>EDIT:</p>
  <p>Well, it seems the problem is with CORS.  Still digging.</p>