title: AjAX post request trouble redirecting the page
body: <p>I'm trying to redirect to a different webpage on the success of an AJAX post request with express, but I can't figure it out.</p>
  
  <p>I've tried using <code>res.redirect()</code> on the server side, and <code>window.location=url</code> and <code>location.href=url</code> and <code>location.replace(url)</code> on the client side, but none of these are working for me.</p>
  
  <p>Here's my jQuery ajax request:</p>
  
  <pre><code>function addContact(){
    var contactName = $('#name').val();
    var email = $('#email').val();
  
    var newContact = {name: contactName, email: email};
  
    $.post('/contacts/add', newContact)
      .success(function(data){
        location.href = data.redirect;
      })
  }
  </code></pre>
  
  <p>And here's my server code:</p>
  
  <pre><code>router.post('/add', function(req, res, next){
      fs.readFile('./contacts.json', function(err, data){
        if (err) return res.status(400).send(err);
  
        var contactArr = JSON.parse(data);
        var newContact = req.body;
        contactArr.push(newContact);
  
        fs.writeFile('./contacts.json', JSON.stringify(contactArr),     function(err){
          if (err) return res.status(400).send(err);
          res.redirect('/');
        });
      });
  });
  </code></pre>
  
  <p>Any help would be appreciated!</p>