There is a qualification to "ask." It is to "ask in my [Jesus'] name." It is like asking according to God's will, only Jesus gives us a better understanding of God's will.
Ancient Judaism used “name” in so many overlapping senses that the context tells us more here than the background. In the Old Testament “name” often meant reputation or renown, and when God acted “on account of his name” it was to defend his honor. “In the name of God” could mean as his representative acting on his behalf (Ex 5:23; Deut 18:19–22; Jer 14:14–15), according to his command (Deut 18:5, 7), by his help (Ps 118:10–11; Prov 18:10) or using his name in a miraculous act (2 Kings 2:24). (When rabbis passed on traditions “in the name of” other rabbis it simply means that they were citing their sources, their basis of authority for the tradition.) In prayer, calling on a deity’s name simply meant addressing him (1 Kings 18:24–26, 32; 2 Kings 5:11; Ps 9:2; 18:49). In the Old Testament and later Judaism “Name” could also simply be a polite and roundabout way of saying “God” without uttering his name.
In this context “name” means something like: those who seek his glory and speak accurately for him, who are genuinely his authorized representatives. Nothing could be further from the pagan magical use of names that sought to manipulate spiritual forces for one’s own ends.
Keener, C. S. (1993). The IVP Bible background commentary: New Testament (Jn 14:12–14). Downers Grove, IL: InterVarsity Press.
In My name (vv. 13–14) is not a magical formula of invocation. But the prayers of believers, as Christ’s representatives doing His business, will be answered. John expanded this teaching in his first epistle. He wrote, “If we ask anything according to His will … we have what we asked of Him” (1 John 5:14–15). To ask Me for anything in My name means to ask according to His will (cf. “in My name” in John 15:16; 16:23–24, 26). The word “Me” is omitted in some Greek manuscripts but it is probably correct here. Prayers in the New Testament are usually addressed to God the Father, but prayer addressed to the Son is proper also (e.g., Stephen’s prayer to the “Lord Jesus” [Acts 7:59]). The goal of answered prayers is to bring glory to the Father. Also bearing fruit glorifies the Father (John 15:8).
Blum, E. A. (1985). John. In J. F. Walvoord & R. B. Zuck (Eds.), The Bible Knowledge Commentary: An Exposition of the Scriptures (Vol. 2, p. 323). Wheaton, IL: Victor Books.
The name of Jesus means much more than we usually ascribe to it. The name, Jesus (Yeshua means “He saves”), is a powerful symbol of the combined essence of all that Israel’s anointed King is; what he says and what he does. To ask something in the name of Jesus is to ask because of who he is, of what he says, and of what he does. There is indeed power in his Name, and we must seek no other. However, we must realize that it is not a simple addendum, or a “send” button, to our prayers. In spite of popular belief, we can pray in Jesus’ name without actually ending our prayer with the well-known phrase: “in Jesus’ Name. Amen.” The main thing here is that Jesus becomes the focal point of Israelite worship, the center of Israelite life. It was not Mt. Gerizim (like for Samaritan Israelites) and not Mt. Zion (like for Judean Israelites) which was the center of God’s presence – but Jesus, and him alone.
Lizorkin-Eyzenberg, Eli. The Jewish Gospel of John: Discovering Jesus, King of All Israel (p. 207). Jewish Studies for Christians. Kindle Edition.