title: jQuery ajax with ES6 Promises
body: <p>I am trying to make a post request via jQuery using an ES6 promise:</p>
  
  <p>I have a function:</p>
  
  <pre><code>getPostPromise(something, anotherthing) {
    return new Promise(function(resolve, reject) {
      $.ajax({
        url: someURL,
        type: 'post',
        contentType: 'application/json; charset=utf-8',
        data: JSON.stringify(
          something: something,
          anotherthing: anotherthing
        }),
        dataType: 'json',
        success: resolve,
        error: reject
      });
    });
  }
  </code></pre>
  
  <p>and I call it like so:</p>
  
  <pre><code>getPostPromise(
    'someFooStuff',
    'someBarStuff'
  ).then(
    function(returnedData) {
      console.log("Good: ", returnedData);
    },
    function(responseObject) {
      console.log("Bad: ", responseObject);
    }
  ).catch(
    function(errorThrown) {
      console.log("Exception: ", errorThrown);
    }
  );
  </code></pre>
  
  <p>My server is returning a response as expected with the request body being in JSON format but my console output is:</p>
  
  <blockquote>
    <p>Good: undefined</p>
  </blockquote>
  
  <p>Why am I not getting the returned data?</p>
  
  <p>Thanks to anyone/everyone for any help.</p>
  
  <p>--- UPDATE EDIT ---</p>
  
  <p>I have reduced my js to only:</p>
  
  <pre><code>import $ from 'jquery';
  $.get('http://localhost:8008/api/user')
    .done(function(data) {
      console.log(data);
    });
  </code></pre>
  
  <p>I still get undefined as output.  If I open up the request in the network tab I can see the response object with the correct data.  The request is made, my server is happy and responds, and the results are in my browser but the data parameter of done is undefined. I am stumped.</p>
  
  <p>--- UPDATE 2 - SOLUTION FOUND ---</p>
  
  <p>I discovered that the problem was with using: <a href="https://github.com/jpillora/xdomain" rel="noreferrer">https://github.com/jpillora/xdomain</a> to get around CORS.  It would seem that that library screws up passing back values somehow.  I have removed it and will implement CORS properly and to hell with browsers that don't support it.</p>