Can you ready dispel magic to stop another spell from taking effect?

The easiest way to stop a spell is to cast counterspell on its caster while it’s being cast. If successful, counterspell interrupts the other spell’s casting, and that spell fails to take effect. Counterspell works against any spell, regardless of a spell’s casting time or duration.

With the Ready action, dispel magic can be cast in response to another spell being cast, yet dispel magic can’t substitute for counterspell. The main reason is that dispel magic removes a spell that is already on a target, whether that target is a creature, an object, or some other phenomenon. Dispel magic can’t dispel something in advance. If a spell isn’t already present on a target, dispel magic does nothing to that target. The best that a readied dispel magic can do is dispel a spell immediately after the spell has been cast to prevent it from having any effect after the action used to cast it. For example, on your turn you could say something like this: ”I ready dispel magic, and if the high priest casts a spell on anyone, I cast dispel magic on the target if the spell takes hold.” If the high priest then cast hold person on your companion who fails the save against it, you could unleash your readied dispel magic and end hold person.