title: Cannot access variables within a promise
body: <p>I'm trying to create a JavaScript object (friends_ringsigs), in which the keys are the values of names[i], and the values are the "result" variable created at the execution of the promise. The problem is, when I try to access the "names[i]" variable for use, it doesn't exist.</p>
  
  <pre><code>// get list of new contact requests
  $.ajax({
      url: '/api/messaging/getnewfriends.php?auth=&lt;?=$_SESSION['auth_random']?&gt;',
      type: 'POST',
      data: '',
      success: function(result) {
          if(result != 'none'){
              var names = result.split("[Delimiator0]");
              for(var i = 0; i &lt; names.length-1; i++){
                  ringsig_decrypt(priv_ck, names[i]).then(function(result){
                      friends_ringsigs[result] = names[i];
                      alert(friends_ringsigs[result]);
                      alert(names[i]);
                      alert(result);
                      document.getElementById('newcontactslist').innerHTML += contactify(result);
                      $('#contactslabel').show();
                  });
              }
          }else{
              document.getElementById('newcontactslist').innerHTML = "";
              $('#contactslabel').hide();
          }
      }
  });
  </code></pre>
  
  <p>I'm able to access the "result", but not the names[i], and later when I go to get the value out of friends_ringsigs, it doesn't exist. In fact, alert(JSON.stringify(friends_ringsigs)); outputs "{}".</p>