title: how to get variable out of function(){ $.get() return variable; } function ? in jquery?
body: <p>I am trying to get a variable out of a function. This function includes a <code>$.get()</code> function inside. Here is the code:</p>
  
  <pre><code>$(function () {
    var valiable = '';
    function functionName(string) {
        var file = "lang.txt";
        $.get(file, function (txt) {
            var lines = txt.split("\n");
            for (var i = 0, len = lines.length; i &lt; len; i++) {
                if ($.trim(lines[i]) == string) {
                    valiable = lines[i];
                }
            }
        });
        return valiable;
    }
  
    $('#button').on('click',function () {
     var variable = functionName(string);
     console.log(variable);
     });
  
  });
  </code></pre>
  
  <p>I'm trying to parse a <code>.txt</code> file to get its content.</p>