title: Javascript return doesn't work? returns undefined
body: <p>I got a wierd issue with a javascript script.</p>
  
  <p>This is my code:</p>
  
  <pre><code>function checkDiscountCode()
  {
  
    var discountCode = $('#korcode').val();
    var errorMessage = $('#errorMessage').text();
  
    if(discountCode.length &gt; 2)
    {
  
       $.getJSON( 'calc.php?code=' + discountCode, function( json ) 
       {    
         var color = json.color; 
         var soort = json.soort;
         var waarde = json.waarde; 
         var message = json.message;
  
         if(errorMessage != message)
         {
            $('#error').html('&lt;font color="' + color + '" id="errorMessage"&gt;' + message + '&lt;/font&gt;');
         }
  
         if(message == 'OK!')
         {
            var outputData = soort + '-' + waarde;
            console.log('outputData = ' + outputData);
            return outputData;
         }
  
       });   
    }   
  }
  </code></pre>
  
  <p>The console log give the right data, for example 0-12.00 but when I request this function in another function, for example just a alert(checkDiscountCode()); it says undefined..</p>
  
  <p>Can anyone please help me? I don't see the issue..</p>
  
  <p>Thanks in advance!</p>