title: JavaScript: Variable Value gets lost between functions
body: <p>I have the following code</p>
  
  <pre><code>function updateSliderContent(json) {  //&lt;- json defined here is correct
     var screen_order = json.screen_order.split('_');
     jQuery.each(screen_order, function(i, item) {
        var screen_id = item;
        //at this point it is not, thus the function does not execute whatever is in the if blocks
        if (json[screen_id].action == 'add') {
           //doSomething  
        } else if (json[screen_id].action == 'remove') {
           //doSomthingElse
        };
     }
  }
  </code></pre>
  
  <p>My problem is that somehow, the value of json (which is an object from an AJAX Call) gets lost in the each function of jquery. I have not yet found out why, nor how to solve it. Google does not give me the answer I am looking for.</p>
  
  <h3>Edit 1</h3>
  
  <p>Here is the actual call.</p>
  
  <pre><code>function updateSlider() {
     var screenOrder = '';
     jQuery('div#slider td').each(function(i, item) {
        screenOrder += this.abbr + '_';
     })
     var ajaxData = {
        sid: sid,
        story: story,
        date: theDate,
        screenOrder: screenOrder,
        mode: 'ajax_update_slider'
     };
     jQuery.ajax({
        data: ajaxData,
        dataType: 'json',
        success: function (json) {
           updateSliderContent(json);
        }
     });
     theDate = Math.round(new Date().getTime()/1000.0); //UNIX Timestamp
     sliderTimer = setTimeout('updateSlider();',15000);
  };
  </code></pre>