It is narrated in the book, Dala’il al-Imamah of al-Tabari from Zakariyyah b. Adam who narrated the following incident.
One day, I was in the presence of Imām Ali al-Reza (alayhi salām) when his son, Imam Muhammad al-Jawad (alayhi salām), who was less than four years old, was brought to him. When he was brought in, he struck his palms upon the ground and raised his head towards the heavens and remained engrossed in deep thought for a long time.
Seeing this, Imam al-Reza (alayhi salām) asked him, “May I be your ransom! What are you thinking about?”
Imam al-Jawad (alayhi salām) replied, “I am engrossed in thought regarding the sufferings that befell my mother, Fātimah (Salam ul Allāh alayha). By Allāh! I will bring out those two men from their graves and burn them and then scatter their ashes into the seas.”
Hearing this, Imām Ali ibn Musa al-Reza (alayhi salām) asked his son to be brought closer to him and then he kissed him on his forehead and said, “May my parents be your ransom! You are worthy for this affair (Imāmat).”
[Reference: House of Sorrows, page 161]