Having trouble with ajax call and querying DB
<p>I'm very new to javascript and JQuery. I'm making a web application where I want to perform an ajax call on the front end, then on the backend I'm trying to query my database to get information to send to the front end. </p>

<p>Here is my ajax call:</p>

<pre><code>$.ajax({    type: "POST",
            url: "/offer/disable",
            data: {spaceId: spaceId},
        }).success(function(response, status) {

            unavailableDates = response.unavailableDates;
            console.log("received " + unavailableDates);

        }).fail(function(err, status){
            console.log("failure");

        });


  });
</code></pre>

<p>and here is my post method:</p>

<pre><code>router.post('/disable', function(req, res, next) {

  console.log("disable post method was called");

    //get the dates that are unavailable
    Space.getSpaceById(res.body.spaceId, function(error, space){

        if(error)
            return error;

        console.log(space);
        console.log(space.unavailableDates);
        res.send({unavailableDates: space.unavailableDates});

    });


});
</code></pre>

<p>My ajax call is failing and my db is never being queried. My post method is being called though. I have no idea why this is happening or how to fix it.</p>