The final passage regarding thanksgiving from the gospels is from John's gospel on the occasion of the raising of Lazarus. Only John's gospel mentions the raising of Lazarus.
In this passage, Jesus thanks the Father for hearing Him. Jesus clarifies that He already knew that the Father had heard him, but said this for those standing by (and ultimately for those of us reading).
Lazarus was someone who Jesus loved as friend. Therefore, Jesus raised him from the dead. The Father heard the Son's request to raise Lazarus, because the Father loves the Son. This is an illustration for us of Jesus' mediatorial role.
Jesus loves his people and will raise them from the dead. He does this by sacrificing himself on their behalf. The Father accepts the Son's sacrifice, not because He must, but because he loves the Son. Thus, it is appropriate for Jesus to thank the Father for raising Lazarus.
We too, of course, should thank God for our regeneration, which is accomplished by the work of the Spirit on account of the merits of Christ, by the mercy of the Father to whom be the glory, now and forever.
Jesus said, Take ye away the stone.
Martha, the sister of him that was dead, saith unto him, Lord, by this time he stinketh: for he hath been dead four days.
Jesus saith unto her, Said I not unto thee, that, if thou wouldest believe, thou shouldest see the glory of God?
Then they took away the stone from the place where the dead was laid.
And Jesus lifted up his eyes, and said, Father, I thank thee that thou hast heard me. And I knew that thou hearest me always: but because of the people which stand by I said it, that they may believe that thou hast sent me.
And when he thus had spoken, he cried with a loud voice, Lazarus, come forth. And he that was dead came forth, bound hand and foot with graveclothes: and his face was bound about with a napkin.
Jesus saith unto them, Loose him, and let him go.