If we keep God’s commandments, we will receive what we ask for  -  1 John 3:22

And whatsoever we ask, we receive of him, because we keep his commandments, and do those things that are pleasing in his sight.

If we want our prayers answered, we need to keep God’s commandments and do those things that will please Him. We please Him by following and fulfilling His will for our life.