title: AJAX global vars
body: <p>I'm trying to do this, which returns 'undefined':</p>
  
  <pre><code>$.ajax({
      url : 'curriculum/read_types',
      type : 'GET',
      dataType : 'JSON',
      success : function(data) {
          return data;
      }
  })
  </code></pre>
  
  <p>But if I do this:</p>
  
  <pre><code>$.ajax({
      url : 'curriculum/read_types',
      type : 'GET',
      dataType : 'JSON',
      success : function(data) {
          console.log(data);
      }
  })
  </code></pre>
  
  <p>it writes an entire JSON object on the console, so I know there exists data.</p>
  
  <p>How I can return this data?</p>
  
  <hr>
  
  <p>What I want to do is the next:</p>
  
  <pre><code>var curriculum = {
  add : function() {
      html = [];
  
      html.push('&lt;select name="type" required&gt;');
      html.push('&lt;option value="0"&gt;Grupo general...&lt;/option&gt;');
  
      var types = curriculum.read_types();
      $.each(types, function(k,v) {
          html.push('&lt;option value="'+v+'"&gt;'+v+'&lt;/option&gt;')
      })
  
      html.push('&lt;/select&gt;');
  
      content.show('Añadir imagen a curriculum',html.join(''));
  },
  read_types : function() {
      $.getJSON('curriculum/read_types', function(data) {
          return data;
      })
  }
  }
  
  curriculun.add()
  </code></pre>
  
  <hr>
  
  <p>Finally it managed but with a asyn:false request:</p>
  
  <pre><code>var curriculum = {
  add : function() {
      html = [];
      html.push('&lt;select name="type" required&gt;');
      html.push('&lt;option value="0"&gt;Grupo general...&lt;/option&gt;');
  
      var types = curriculum.read_types();
      $.each(types, function(k,v) {
          html.push('&lt;option value="'+v+'"&gt;'+v+'&lt;/option&gt;')
      })
  
  
      html.push('&lt;/select&gt;')
      content.show('Añadir imagen a curriculum',html.join(''));
  },
  read_types : function() {
      var a;
      $.ajax({
          url : 'curriculum/read_types',
          type : 'GET',
          async : false,
          contentType : 'JSON',
          success : function(data) {
              a = data;
          }
      })
      return a;
  }
  }
  </code></pre>