John 14:14 "If ye shall ask any thing in my name, I will do it."
14:15 "If ye love me, keep my commandments."
When our prayers are not answered we generally have one of two recourses: God won't, or God can't. Of course we fail to consider that we often face God with conflicting demands: among people or within a person.
In the Civil War just as many prayers went up to God from the Rebs as from the Union. Who was God to answer? Every nation at war has prayed for victory. So according to primitive thinking the present war will show whether Jehovah or Allah will be most powerful.
Or take the internal case: some prayers raised would destroy the pray-er. I prayed one prayer long ago, and very soon I began 'unpraying' it as hard as possible.
For effectual prayer, as James said, it helps to be a righteous person. The two verses from John make it obvious that the efficacy of prayer depends upon the intention of the supplicant. If I'm in God's will at that moment, my prayer will take wings. Otherwise, I'm wasting my time.
Finally, God has time. For 40 years American Christians prayed fervently for the end of the communist treat. Then it happened. God's time frame is very different from ours.
Some Quakers say they don't pray for people, which only means that they prefer their own tribalistic jargon, which in this case is to "hold you in the light". That seems awkward some times. I've never experienced any annoyance at my prayers in meeting. Quakers are liberal and tolerant, but they do have their own jargon....
Praise the Lord.