res.send not working properly
<p>I am working with a simple CRUD app with jquery ajax and node.js, just to improve my skills with node and ajax. The thing is that I am doing a post request that is handled with my post router in the node server, and everything is working fine. It adds 1 more product to my products.json file, but in the end it doesn't send the response back to the client, the final res.send("done") doesn't work and I don't know why..</p>

<p><strong>here is the code:</strong></p>

<p><strong>ajax</strong></p>

<pre><code>$("#create-form").on('submit',function(){
    event.preventDefault();
    var createIn = $("#create-input").val();
    $.ajax({
        url: '/products',
        method:'POST',
        data:JSON.stringify({name:createIn}),
        contentType: "application/json",
        dataType: "json",
        success: function(data){
          console.log(data);
          $("create-input").val("");
          $("get-button").click(); 
        }
    });
})
</code></pre>

<p><strong>node</strong> </p>

<pre><code>app.post('/products',function(req,res){
    fs.readFile('products.json','utf8',function(err,data){
        var result = JSON.parse(data);
        var productName = req.body.name;
        console.log(req.body.name);
        currentId++;
        var productId = currentId;
        var product = {
            name: productName,
            id: productId
        }
        result.products.push(product);
        fs.writeFile(__dirname + "/products.json",JSON.stringify(result),'utf8');
     });
    res.send("post done");
});
</code></pre>

<p>This is just the important part of the code, it works and just fails at the end in the res.send. </p>