The author (may Allah shower blessings on him) mentioned this hadeeth under the chapter, Indignation against the transgression of the Divine Laws, in his book, Riyaad us-Saaliheen. The Prophet ﷺ noticed a spittle in the direction of the Ka'bah in the mosque. The Prophet ﷺ became angry and removed the substance with his hand saying: ‘Verily, each of you is holding a communion with his Lord’, that is, when such is observing the Salat, he is but talking with his Lord.
It has been documented in the Saheeh that when a slave stands up in Prayer and says: “All the praises and thanks be to Allah, the Lord of the ‘Alamin (mankind, jinns and all that exists).”, Allah will respond: ‘My slave has praised Me’. And when the slave says: “The Most Beneficent, the Most Merciful.” Allah will respond: ‘My slave has mentioned My attributes to praise Me’. And when the slave says: “The Only Owner (and the Only Ruling Judge) of the Day of Recompense (i.e. the Day of Resurrection)”. Allah will respond: ‘My slave has extolled me’. And when the slave says: “You (Alone) we worship, and You (Alone) we ask for help (for each and everything).” Allah will respond: ‘This is between Me and My slave’. And when the salve says: “Guide us to the Straight Way”, Allah will say: ‘This is for My slave, and for him is what he asks for’x(1).
So you are communicating with Allah- the Mighty and Sublime - by means of His Words, calling on Him, praising Him, extolling Him, and exalting Him. Allah- the Mighty and Sublime - is between you and the Qiblah. Although Allah- the Mighty and Sublime - is on His Throne above the heavens, He- the Mighty and Sublime - is before you, because He encompasses all things:
“There is nothing like unto Him, and He is the All-Hearer, the All-Seer.” [Shuurah: 11].
And after the Prophet ﷺ mentioned the prohibition of blowing spittle in the direction of the Qiblah, then he mentioned the permissible thing to do. This is guidance and wisdom - when you tell people about a prohibition, you should mention what is permissible in order not to close all doors against them.
Therefore, the Prophet ﷺ commanded whoever wants to expel spittle to turn to his left side, beneath his feet or utilise his cloth, then fold it. Therefore, these are three options: spit under the feet and trample on it, or spit to the left; these two are impracticable if one is in the mosque since it will soil the mosque. The Prophet ﷺ has said: ‘Blowing the spittle in the mosque is a sin...(1)’ Hence, he should spit into his cloth and fold it.
There is evidence in this Hadeeth that spittle is not an impurity because the Prophet ﷺ permitted the person praying to blow the spittle below his feet or in his cloth. If it were an impurity, he would not have permitted blowing it into the cloth. And this Hadeeth contains an instance of teaching with action because the Prophet ﷺ said: ‘Or he should say like this’ and he spitted into his cloth and folded it.
There is evidence in this Hadeeth for referring to an action as ‘speech’. This is evinced in his statement ﷺ: ‘Or he should say like this’ to be ‘or he should do like this’.
It also contains evidence that there is nothing wrong in a person spitting in front of others especially if it is for teaching purpose.
There is evidence in this that it is part of good manner not to
display what people deem as filthy on your cloth. He ﷺ squeezed it so that its form does not remain on the cloth, otherwise people would be irritated and detest it whenever they see it. Hence, one must be clean in his appearance, clothing and other aspects so that people will not be sick of his appearance.
The point of reference in the Hadeeth was that the Prophet ﷺ became angry when he saw a spittle in the mosque, and this was apparent on his face.
Allah Alone grants success.