私の質問は簡単です。これは私のコードですが、このコードを改善/短縮するにはどうすればよいですか?
それらは多くの点で似ていることがわかりました。そのため、ここで質問しています。
ここに私のコードがあり、助けていただければ幸いです。
$(".follow-link").click(function(event) {
    event.preventDefault();
    var therel = $(this).attr('rel');
    var followID = $(this).attr('rel').replace(/[^0-9]/g, '');
    var thisfollow = $(this);
    $.ajax({
        url: '/ajax/follow.php',
        type: 'POST',
        data: {followwho : followID},
        dataType: 'json',
        success: function(data){
            if (data.status) {
                $('a[rel="' + therel + '"]').hide();
                $('a[rel="' + therel + '"]').parent().children('.unfollow-link').fadeIn();
            }
        }
    });
});
$(".unfollow-link").click(function(event) {
    event.preventDefault();
    var therel = $(this).attr('rel');
    var followID = $(this).attr('rel').replace(/[^0-9]/g, '');
    var thisfollow = $(this);
    $.ajax({
        url: '/ajax/unfollow.php',
        type: 'POST',
        data: {followwho : followID},
        dataType: 'json',
        success: function(data){
            if (data.status) {
                $('a[rel="' + therel + '"]').hide();
                $('a[rel="' + therel + '"]').parent().children('.follow-link').fadeIn();
            }
        }
    });
});