When Jesus heard of the death of John the Baptist, he withdrew on a boat to a
deserted place by himself. (Matt 14:13)
We know from John's Gospel (John 11:35) that Jesus wept for Lazarus's death. It's reasonable that Jesus cried, too, for His cousin John.
He took a little time to Himself to mourn John's death, yet Jesus, of all people, would know well that John is safe in heaven. The psalmist reminds us that the Lord is good and compassionate (Ps 145:9), and Paul wrote his belief that death cannot keep us from God. (Rom 8:35, 37-39) So why would Jesus mourn?
It is human to mourn. We cannot forget that Jesus is not only fully God but also fully man. Jesus missed John and knew that they were seperated in some ways, if only for a time. Jesus gives us the perfect example of humanity, even in His mourning. After He returned from His time alone, He carried on doing the Father's will.
As Paul wrote, present things - even something as terrible as John's brutal death - cannot keep us from the love of God. We endure and hope and go on in love.