I know, this is another section that appears to be disconnected with Jesus' teaching on not judging your brother. Sure, it's possible that Jesus might be changing the subject here, except that if you skip down to verse 12 he says, "Therefore, however you want people to treat you, so treat them, for this is the Law and the Prophets." The "therefore" means he is summing up all that he had just previously said. What's more, the concluding exhortation "however you want people to treat you, so treat them" does happen to sum up nicely what he says about "do not judge lest you be judged."
In other words if you get your Bible out and look at the whole passage, 7:1-12, you'll see that verses 1 and 2 sound similar to verse 12. And verse 12 has the "therefore" in it, which is a word that signals "concluding statement here." So my idea is that this entire section, verses 1-12, belongs together as a single unit and is talking about the same theme. That means our passage today on "ask and it will be given to you" must also fit into this topic of not judging and of treating others as you would want to be treated. (I hope this is making sense. It's always so annoying when Bible studies get overly technical.)
"Ask and it shall be given to you, seek and you shall find, knock and it shall be opened to you" is such a practical, encouraging exhortation that I really do think it could be applied your prayer life in general. But specifically in this context I think Jesus is talking about prayer for wisdom in dealing with others. On one hand you don't want to judge people, but on the other hand you will want to take that speck out of your brother's eye without being a hypocrite about it. And even after you've first taken the log out of your own eye, you still have to beware of casting your pearls before swine. You don't want to share counsel that isn't welcome and wind up getting attacked yourself.
How do you navigate your way around such a situation? How do you have the discernment to tell what is the right course of action? Pray to God for wisdom. Ask, seek and knock, and you won't be denied.
Is this too narrow an understanding of the "ask, seek, knock" teaching on prayer? Well, as I said I don't think you have to apply this promise only to asking for wisdom in your life, but since the context does seem to slant the application in the this direction, it's also interesting to note that the epistle of James says:
"But if any of you lacks wisdom, let him ask of God, who gives to all men generously and without reproach, and it will be given to him" (1:5).
James seems to echo this very teaching of Jesus' when he repeats the promise of "ask . . . and it will be given to [you]," except he applies it specifically to asking for wisdom. And like Jesus' teaching, James roots this promise in the generous nature of God "who gives to all men generously and without reproach."
Jesus promises that God will not withhold "good gifts" from his children, just as an earthly father would never withhold good gifts like bread or fish from his earthly children. Frankly, I remember asking God for many things that he never gave me, and I'm sure you've experienced the same. I can only conclude that God did not consider what I asked for to be something good for me at the time.
Yet wisdom is always a good gift, isn't it? Can you imagine asking God for wisdom with a sincere heart and not receiving it? Wisdom is the best of gifts. God was pleased when Solomon asked for wisdom instead of riches or power. By making that request he showed his heart was in the right place. The same goes for us. Wisdom tells us how to deal with people, how to avoid offending a brother or getting entangled with an enemy, how to know when to speak and when to shut up. The practice of prayer is mysterious to us sometimes, but it's nice to know that wisdom is one surefire thing you can ask for and will never be denied.