Reputation: 1244
I've got the following ajax call:
function sendRequest(quote, author){
$.ajax({
type: "POST",
url: window.location.pathname,
data: {quote: quote, author: author},
dataType: JSON,
success: function(){console.log("Data sent!");},
error: function(error){console.log("ran into an error")}
});
}
And here is my server (using express) handling the post request,
app.post("/", function(req, res){res.status(200).end("Success!")});
However, the console doesn't print "Data Sent
". Instead, it prints "ran into an error
"
Everything else is tested and is working correctly
Upvotes: 0
Views: 1766
Reputation: 1433
First of all dataType should be 'json'
not JSON
Then check the console log for specific error.
Upvotes: 1