I am working on my practical / game project (just started with jQ and Ajax), and the problem is that I cannot get my game as different from the button (mark / unmark in my application).
This is my code (some of node js stuff is also a button, I think it’s not a problem, because it works as expected (I can save the “tagged materials” in my database, etc.)):
$('a.mark_button').on('click', function(event) {
event.preventDefault();
$(this).html('Unmark').removeClass('mark_button').addClass('unmark_button');
$.ajax({
url: '/mark',
type: 'POST',
contentType: 'application/json',
dataType: 'json',
data: JSON.stringify({ id:$(this).attr('id') }),
complete: function() {
console.log('Process completed!');
},
success: function() {
console.log('Successfully');
},
error: function() {
console.log('Failed');
}
});
});
$('a.unmark_button').on('click', function(event) {
event.preventDefault();
$(this).html('Mark').removeClass('unmark_button').addClass('mark_button');
$.ajax({
url: '/unmark',
type: 'POST',
contentType: 'application/json',
dataType: 'json',
data: JSON.stringify({ id: $(this).attr('id') }),
complete: function() {
console.log('Process completed');
},
success: function() {
console.log('Succesfully');
},
error: function() {
console.log('Failed');
}
});
});
, , , "MARK", , ajax- ( .., ( )) , "UNMARK" ( facebook / ), , . , , , "unmark_message", "" . , , ajax .
, ( "" ).