I have a container method for an ajax
request:
function postRating(formData) {
$.ajax({
type: "POST",
url: '/api/ratings',
data: formData
})
.done(function () {
return true
})
.fail(function () {
return false
})
.always(function (msg) {
//console.log(msg);
});
}
which is called like so:
$('.episode-rating.like').click(function () {
var formData = $("#episode-rating").serializeArray();
formData.push({name: 'up', value: 1}, {name: 'down', value: 0});
console.log(postRating(formData))
});
However postRating()
returns undefined
. Not sure what I'm doing wrong. I want to do some html processing if the ajax request is successfull and show an error otherwise.