And I will do whatever you ask in my name, so that the Son may bring glory to the Father. You may ask me for anything in my name, and I will do it. John 14:13-14
If you remain in me and my words remain in you, ask whatever you wish, and it will be given you. John 15:7
In that day you will no longer ask me anything. I tell you the truth, my Father will give you whatever you ask in my name. Until now you have not asked for anything in my name. Ask and you will receive, and your joy will be complete. John 16:23-24
Some people take these verses to mean that they can have whatever they want. They treat God like a giant vending machine. As long as the prayer goes in the slot they can choose whatever tit-bit takes their fancy.
Answered prayer is one of the terms of the New Covenant, but there are conditions attached.
In The Name of Jesus
In John 14 the condition is that we ask in the name of Jesus.
That does not mean simply tacking "in the name of Jesus" to the end of our prayer.
To do something in the name of another is to act on their behalf, such as a police officer acting on behalf of the law or an executor carrying out the requests of a deceased person.
So, to ask in the name of Jesus is to ask according to His will. We need to find out what Jesus wants. When we pray in line with His will, our prayers will be answered.
In Line With The Words of Jesus
In John 15 the condition is that we remain in Jesus and His words remain in us.
This is how we know what the will of Jesus is - we get as close to Him as we can and we fill ourselves up with His word. In simple terms, we fellowship with Him in prayer and we spend time reading the Bible.
The apostle Paul put it this way:
Do not conform any longer to the pattern of this world, but be transformed by the renewing of your mind. Then you will be able to test and approve what God’s will is—his good, pleasing and perfect will. Rom 12:2
In fact, the words of Jesus are very clear:
So do not worry, saying, ‘What shall we eat?’ or ‘What shall we drink?’ or ‘What shall we wear?’ For the pagans run after all these things, and your heavenly Father knows that you need them.But seek first his kingdom and his righteousness, and all these things will be given to you as well. Therefore do not worry about tomorrow, for tomorrow will worry about itself. Each day has enough trouble of its own. Matt 6:31-34
Prioritise the extension of the kingdom of God and pursue righteousness. These are the chief things for which Jesus would have us pray.
The purpose of prayer is not to see our desires met, but God's plans fulfilled.