Praise be to Allah.
If a fasting person swallows his saliva that does not invalidate his fast even if there is a lot of it and if that happens in the mosque or elsewhere. However if it is thick like mucus, he should not swallow it, rather he should spit it out into a tissue or whatever if he is in the mosque.
And Allaah is the Source of strength. May Allah send blessings and peace upon of Prophet Muhammad and his family and companions.
Al-Lajnah al-Daa’imah li’l-Buhooth wa’l-Ifta, 1-/270.
If it is asked, is it permissible to swallow mucus deliberately?
The answer is:
It is haraam to swallow mucus whether one is fasting or not, because it is considered to be dirty and it may carry diseases produced by the body. But it does not break the fast if a fasting person swallows it, because it does not come from blood and swallowing it is not regarded as food or drink. If he swallows it after it reaches the mouth, it does not break the fast. From the words of Shaykh Muhammad ibn ‘Uthaymeen, may Allaah have mercy on him. See al-Sharh al-Mumti’, 6/428.