"When we go to God with a request that He modify the existing situation for us, that is, that He answer prayer, there are two conditions that we must meet: (1) We must pray in the will of God and (2) we must be on what old-fashioned Christians often call "praying ground"; that is, we must be living lives pleasing to God.
It is futile to beg God to act contrary to His revealed purposes. To pray with confidence the petitioner must be certain that his request falls within the broad will of God for His people.
The second condition is also vitally important. God has not placed Himself under obligation to honor the requests of worldly, carnal or disobedient Christians. He hears and answers the prayers only of those who walk in His way...(1 John 3:21-22; John 15:7)....
The truth is that God always answers the prayer that accords with His will as revealed in the Scriptures, provided the one who prays is obedient and trustful. Further than this we dare not go." - A. W. Tozer