title: How to store a Json coming from Ajax in a global variable?
body: <p>I am not able to store a Json that I get through Ajax in Jquery in a global variable, it only works inside the function.</p>
  <pre><code>let ingJson;
  let masasJson;
  let salsasJson;
  
  searchIngredients();
  console.log(ingJson);
  </code></pre>
  <p>Here <code>log</code> throws me an<code> undefined</code> error when I need the Json returned to me so I can use it in the rest of the code.</p>
  <pre><code>function searchIngredients(){
      let origin = `/ingredientes.json`;
      $.get(origin).then(htmlIngredients);
  }
  function htmlIngredients(res){
      ingJson = res.ingredientes;
      masasJson = res.masas;
      salsasJson = res.salsas;
      console.log(ingJson);
  }
  </code></pre>
  <p>Here <code>log</code> returns the Json correctly.</p>