The Quran says: 'When My servants ask you about Me, I am near. I answer the call of the caller when he calls on Me.' It also says: 'Call on Me, I will respond to you,' and, in a verse about fighting that states a wider principle, that you may dislike something that is good for you and like something that is bad for you, and Allah knows while you do not. A prayer that is not granted in the form requested is not necessarily a prayer that was ignored: a person asks with limited knowledge, and Allah answers with complete knowledge.
The Prophet ﷺ said that a servant's prayer continues to be answered as long as he does not ask for something sinful or for cutting off family ties, and as long as he is not impatient. He was asked what impatience is and said that it is to say 'I prayed and prayed and did not see it answered,' and then to give up and leave off praying. The Quran gives examples of prophets who prayed and waited. Job called to his Lord that adversity had touched him, and that He is the Most Merciful of those who show mercy, and Allah removed it and gave him back his family and more. Zechariah, peace be upon him, said that he had never been unblessed in praying to his Lord.
Honestly, there are prayers that hurt the most when they are not answered: a sick child, a lost loved one. For those who face this, Islam does not give a formula that makes the pain vanish. It teaches that prayer is itself worship and that its reward is with Allah, that many believers find inner calm to be part of the answer, and that what is withheld in this world is not lost. The Prophet ﷺ also taught the prayer of consultation (istikhara), asking Allah to decree what is good for one's religion, livelihood and end, and then to make one content with it. Keep asking, and keep trusting.