When Prayer is Answered

I would like to know how is a prayer answered. When is it answered and when is it not? What is the impact of the group of people praying for a person whom they might know or not know? I have had both kind of experiences of prayer being heard and not heard. I have a feeling that probably it takes time for a prayer to be answered.