Ajax POST每次都失败

I have tried multiple ways of sending a post, such as a XMLHttpRequest. All of them ended in the post failing.
I am using XAMPP to run the webpage this is for.

JS

var obj = {
        title: $("form input[name=title]").val(),
        desc: $("form input[name=desc]").val(),
        etc...
    };
$.post("newpost.php", {data: JSON.stringify(obj)}, function(response){
    console.log("Response: "+response);
}).fail(function(result){
    console.log("Fail "+result);
});  

PHP

echo $_POST["data"];