too long

So I have some code that allows the user to click on an icon to save that item to their favorites or remove from favorites. I want to change the icon using jquery/AJAX. I am wondering how to return the code from the PHP file to update the page without reloading. Essentially I would like to update the color of the heart icon and add or remove the word 'Save'.

Here is my AJAX code for displaying the div:

function deleteLink( deleteID ){

var deletedID = deleteID;

$.ajax({
    method: "POST",
    url: "deleteLink.php",
    dataType: "json",
    data:  { 'deletedID' : deletedID },

    success: function(deleteIDFunc){
        var deleteIDFunc = $.trim(deleteIDFunc);
        if(deleteIDFunc){               
            $('#removeSaved').html(deleteIDFunc); //<-how can I change the div so that it will display the other icon
        }
        else {
            alert('Your saved post was not removed. Please try again');
        }
    }
});
}

Here is my Database code for deleting and updating the database: this updates and works properly.

function check_input($dirtData) {
  $dirtData = trim($dirtData);
  $dirtData = strip_tags($dirtData);
  $dirtData = stripslashes($dirtData);
  $dirtData = htmlspecialchars($dirtData);
  $dirtData = filter_var($dirtData, FILTER_SANITIZE_STRING);
  return $dirtData;
}

if(isset($_POST['id'])){

$ID = check_input($_SESSION['user_session']);
$link_id = check_input($_POST['id']);

$query = "INSERT INTO savelink (saveUser_id, link_id) VALUES ($ID, $link_id)";
$stmt = $conn->prepare($query);
$stmt->execute();

$returnID = "ok";
echo $returnID;
}else{
    return false;
}

if(isset($_POST['deletedID'])){

$id = check_input($_POST['deletedID']);

$query = "DELETE FROM savelink WHERE saveLink_id = :id";
$stmt = $conn->prepare($query);
$stmt->bindParam(':id', $id);
$stmt->execute();

$deleteIDFunc = '';  //<-do I need to put some html code here and then return json for changing the div
echo json_encode($deleteIDFunc);
}else{
    return false;
}

Lastly here is the code where the item is displayed:

if(isset($_SESSION['user_session']) && $row['saveUser_id'] == $_SESSION['user_session']){
    $returnNew .= '<span id="removeSaved"><a href="javascript:void();" class="pull-right" onclick="deleteLink('.$row['saveLink_id'].');"><i class="fa fa-heart" style="color:#d52917;"></i></a></span>';
}
else if(isset($_SESSION['user_session'])){
    $returnNew .= '<span id="showSaved"><a href="javascript:void();" class="pull-right" onclick="saveLink('.$row['topic_id'].');">Save <i class="fa fa-heart"></i></a></span>';
}

Its simple,

you can add after the following content in "showSaved" to the "removeSaved" div and make "removeSaved div hide.

eg as follows :-

$.ajax({
    method: "POST",
    url: "deleteLink.php",
    dataType: "json",
    data:  { 'deletedID' : deletedID },

    success: function(deleteIDFunc){
        var deleteIDFunc = $.trim(deleteIDFunc);
        if(deleteIDFunc){               
            $('#removeSaved').html(deleteIDFunc); //<-how can I change the div so that it will display the other icon
            $('#removeSaved').hide();
            $("#removeSaved").after('<span id="showSaved"><a href="javascript:void();" class="pull-right" onclick="saveLink('+deletedID +');">Save <i class="fa fa-heart"></i></a></span>');

        }
        else {
            alert('Your saved post was not removed. Please try again');
        }
    }
});

Please note the ID to pass, if you want pass the id to the ajax function deleteLink()