title: Why is undefined the ajax response value?
body: <p>I have a function which returns the pictures for 2 type of devices. In <strong>function(response)</strong> i get the value correctly, then autside of <strong>$.post</strong> section the value is undefined.</p>
  <pre><code>function findHeadShot(key) {
            var tip;
            var ajaxUrl = &quot;gettip.php&quot;;
            var data = { action: 'function1', azon: key};
                $.post(ajaxUrl, data, function(response) {
                    tip = response; //Here i get the response, and it is fine yet
                });
                alert(tip);         //Here the response is undefined, but why?
                switch (tip) {
                  case &quot;pc&quot;:
                     return &quot;pc_icon.png&quot;;
                    break;
  
                  case &quot;server&quot;:
                     return &quot;server_icon.png&quot;;
                    break;
                
                  default:
                    return &quot;server_icon.png&quot;;
                    break;
                }
        }
  </code></pre>