Code after Javascript for loop with Ajax not executing
<p>Why is the "hello" alert at the end of this code not executing? Everything else is working fine, but the alert doesn't fire. What am I missing? PS, I am a beginner when it comes to Javascript...</p>

<pre><code>$('.save_button').click(function(){
  var numItems = dataseries.length;
  var item;
  var sequence;
  var question = &lt;%=@question.id%&gt;;
  for (i=0;i&lt;numItems;i++){
    var requestObj = {
      question_id: "&lt;%=@question.id%&gt;",
      user_id: "1",
    }
    item = $('.item_list li[data-seq='+i+']').attr('id');
    requestObj["item_id"] = item.toString();
    requestObj["x"]= dataseries[i][0][0];
    requestObj["y"]= dataseries[i][0][1];
    if (requestObj["item_id"]!="null"){
      var a = $.ajax({
        url: "&lt;%=responses_path%&gt;",
        data: requestObj,
        type: "POST",
        dataType: 'script',
        success: function(data, textStatus, jqXHR) {
        },
        error: function(jqXHR, textStatus, errorThrown) {
          alert('error!');
        },
        headers: {
          'X-CSRF-Token': '&lt;%= form_authenticity_token.to_s %&gt;'
        }
      });
    }
  }
  alert("hello");
});
</code></pre>
