JQuery Promise failing on ComponentDidMount React.JS
<p>In my components' ComponentDidMount life cycle method, I'm attempting to initiate an AJAX request to get data client-side (Data needs to be available when app has loaded). Upon inspection, I've noticed that my promise chain keeps deferring to the <code>fail</code> property. This is confusing because, upon inspection via the Chrome Developer tools, the request is made and data is successfully returned to the promise (see Screenshot). I suspected it could be the speed at how fast my component loads, and I tried a componentWillMount life cycle method, and it yields the same results. I was retrieving data fine, synchronously via an AJAX request, but I'm now trying to improve the code with asynchronously functionality. </p>

<p>new code tried:</p>

<pre><code>componentDidMount: function(){ 
      var returnedClassesString;

      var user = window.globalValue;

      function getQueries(user){
          returnedClassesString = $.ajax("/portals/0/js/get_classes_front.aspx?userName="+user).done(function(data,err){
              console.log('good' + data);
          }).fail(function(data,err){
              console.log(err);
          });  

      }

      getQueries(user);



  },
</code></pre>

<p>componentDidMount method:</p>

<pre><code>componentDidMount: function(){ 
      var returnedClassesString;

      var user = window.globalValue;

       $.when($.ajax("/portals/0/js/get_classes_front.aspx?userName="+user)).then(function(data, textStatus, jqXHR) {
          // Handle both XHR objects
          console.log(data);
          }).fail(function(){
                   console.log('failed');
             });
    }
</code></pre>

<p>Screenshot of Chrome Dev-Tools (Network Traffic, I request the first file in the stack):
<a href="https://i.stack.imgur.com/QOE7z.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QOE7z.png" alt="enter image description here"></a></p>

<p>Screenshot of Chrome Dev-Tools (JavaScript console w/ 'failed' message):
<a href="https://i.stack.imgur.com/uUt2w.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uUt2w.png" alt="enter image description here"></a></p>