Reputation: 45
I am trying to send the ID provided when the ajax-call is called to the error message but when I do it this way, the error message gets displayed even if no error message is returned through ajax (likepost_XML.php):
function like(commentid){
$.ajax({
type: 'POST',
url: 'likepost_XML.php',
data: {
comment_id: escape(commentid)
},
success: successlike,
error: errormsga(commentid)
});
}
And this is the Error function:
function errormsga(commentid)
{
console.log(":didn't work bro");
$("#"+commentid).css({"color":"red"});
}
Upvotes: 0
Views: 28
Reputation: 97672
You are calling errormsga instead of setting an error callback function. Wrap the call in a function expression.
error: function(){
errormsga(commentid);
}
Upvotes: 1