Some people would like prayer with no conditions. Prayer has conditions. It's true that Jesus said, "If you believe, you will receive whatever you ask for in prayer" (Matthew 21:22). But, even in that statement, we have one condition to prayer is faith. As we examine the scriptures, we find that there are other conditions to prayer, as well.
Few conditions to prayer:
[1] We are to Pray to the Heavenly Father (see Matthew 6:9). This condition to prayer might seem obvious, but it's important. We don't pray to false gods. We pray to the God of the Bible, who revealed Himself in Jesus Christ and whose Spirit indwells us. Coming to Him as our "Father" implies that we are first His children, made so by faith in Christ as said in John 1:12.
[2] We are to Pray for good things (Matthew 7:11). We don't always understand or recognize what is good, but God knows, and He is eager to give His children what is best for them. Paul prayed three times to be healed of an affliction, and each time God said, "No." Why would a loving God have something better for him, namely, a life lived by grace? Paul stopped praying for healing and began to rejoice in his weakness (2 Corinthians 12:7-10).
[3] We are to Pray for needful things (see Philippians 4:19). Placing a priority on God's kingdom is one of the conditions to prayer (Matthew 6:33). The promise is that God will supply all our needs, not all our wants. There is a difference.
[4] We are to Pray from a righteous heart (James 5:16). The Bible speaks of having a clean conscience as a condition to answer prayer (Hebrews 10:22). It is important that we keep our sins confessed to the Lord. "If I regard wickedness in my heart, The Lord will not hear" (Psalm 66:18).
[5] We are to Pray from a grateful heart (Philippians 4:6). Part of prayer is an attitude of thanksgiving.
[6] We are to pray according to the will of God (1 John 5:14). An important condition to prayer is that it is prayed within the will of God. Jesus prayed this way all time, even in Gethsemane: "Not my will, but yours be done" (Luke 22:42). We can pray all we want, with great sincerity and faith, for so and so, but, if God's will is different, we miss it.
[7] We are to pray in the authority of Jesus Christ (John 16:24). Jesus is the reason we are able to approach the throne of grace (Hebrews 10:19-22), and He is our mediator (1 Timothy 2:5). A condition to prayer is that we pray in His name.
[8] We are to We are to Pray persistently (Luke 18:1). In fact, pray without ceasing (1 Thessalonians 5:17). One of the conditions to effective prayer is that we don't give up.
[9] We are to Pray unselfishly (James 4:3). Our motives are important.
[10] We are to Pray in faith (James 1:6). Without faith, it is impossible to please God (Hebrews 11:6), who alone can do the impossible (Luke 1:37). Without faith, why pray?
Joshua's prayer for the sun to stand still, as audacious as that request was, met all these conditions of prayer (Joshua 10:12-14). Elijah's prayer for rain to be withheld - and his later prayer that rain would fall - met all of these conditions (James 5:17-18). Jesus' prayer as He stood before the tomb of Lazarus met all of these conditions (John 11:41). They all prayed to God, according to His will, for good and necessary things, in faith.
The examples of Joshua, Elijah, and Jesus teach us that, when our prayers line up with God's sovereign will, wonderful things will happen. There's no need to be abashed by mountains, for they can move (Mark 11:23). The struggle we face is in getting our prayers lined up with God's will, having our desires match His. Congruency between God's will and our own is the goal. We want exactly what He wants; nothing more, nothing less. And we don't want anything that He doesn't want.
Godly, effective prayer has conditions, and God invites us to pray. He is God and He will answer our prayers according to His schedule, in His own time, and His perfect will.