The scope of $(this) in the problematic part is the anonymous function returning the data (or maybe the $.post I can’t remember).
After a.PreventDefault(), do this then refer to it instead.
$('.like').on('click', (function (a) {
a.preventDefault();
var $self = $(this);
($self.text() === "Undo") ? $self.text("Like") : $self.text("Undo");
// etc.
That way you can use it throughout the rest of the code fine. $self is not a keyword, I just added the $ to denote to the programmer that it’s already a jQuery variable. You could also use var self = this then refer to it using $(self) later on.
Another thing, the a doesn’t really make much sense to me. I see and use .click(function (e) {}) where e stands for event. The jQuery docs use the whole word event and MDN use evt. Not really a big deal, but a doesn’t seem to make much sense.