title: How to read values in page load in JavaScript?
body: <p>I have an API called <code>dropdown-language</code> that returns something like:</p>
  
  <pre><code>{
    "res": [
      {
        "enabled": 0, 
        "flag": "gr"
      }, 
      {
        "enabled": 1, 
        "flag": "us"
      }
    ]
  }
  </code></pre>
  
  <p>How can I get the two elements on page load and store them in two global variables such as:</p>
  
  <pre><code>var one = { "enabled": 0 , "flag": "gr" }
  var two = { "enabled": 1 , "flag": "us" }
  </code></pre>
  
  <p>So that I can use then in other parts of the same html page? This is what I have done so far:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  $.ajax({
    url: "dropdown-language",
    success : function(data) {
      obj = JSON.parse(data);
      alert(obj);
    },
    async:false
  });
  &lt;/script&gt;
  </code></pre>