Dua has its prerequisites, these are what make a dua heard.
Also I cannot stress enough that the acceptance of the dua in no way will mean an immediate result . It may even be postponed until judgement day; on that day the supplicant will be so overwhelmed that at that moment he will wish that none of his other requests had been granted in the dunya.
When one understands the requirements for acceptance of dua, they will understand why some duas are not answered as they wish.
Nothing escapes the knowledge of the Almighty Allah. There is wisdom behind all His decisions; and due to this a dua being answered is contingent on whether or not it is of benefit to the supplicant or not.
An example is when a child asks his mother if he can play with fire. Would you allow your child to play with fire.
Most of the duas that we make to Allah (swt) are detrimental to us, though we perceive it not.
As one narration states: “There are those amongst My servants for whom only wealth is suitable [as opposed to poverty], and were I to consign them to anything else, they would have certainly perished. And indeed there are those amongst my servants for whom only poverty is suitable, and were I to consign them to anything else, they would have indeed perished.”
Al-Majlisi says the following about response to dua:
1. Allah’s (awj) promise to grant the requests made to Him is conditioned on whether they are in accordance with His will, for Allah (awj) says, He will remove that for which you supplicated Him, if He wished (6:41).
2. Allah (awj) accepts the supplication right away but postpones granting the supplicant’s request so that the latter would continue in his supplication, for the believer is the beloved of Allah (awj) and He loves to hear His beloved.
3. Allah (awj) grants only those requests that are to the advantage of the supplicant.