Here's what happened:
We've reached the end of the campaign, with only the last wave of minions standing between us and the dark sorcerer who's been flooding the local farms and villages with undead. As it comes to find out, literally the only thing between he and us were his minions. From the other side of the room, a perception check tells us that he's beginning to cast a spell. Spellcraft check tells the group wizard that it's an empowered chain-lightning spell, and after a quick taunt, he insures that it's him who will be the primary target of the spell.
Well, here's the hitch. He's prepared a dimension door spell, and has ready-action "teleport away if I'm attacked." The DM makes the call, and a spell that he knows will harm him falls under 'getting attacked' for the purposes of the condition of the readied action.
So, he teleports... behind the sorcerer. But, a few people in the group take issue with this. Here are the two sides of the argument, as they were presented in the group.
His side: The caster no longer knew where he was (this was also a topic of debate, but that's a different issue) and casters aren't allowed to choose 'that guy I know is within range of my spell, even though I have no idea where he is' after the rogue uses a ring of invisibility to vanish.
Other side: He was still within range of the spell, the spell caster had already chosen him as the target of the spell, and the spell specifically states that it goes from the caster's finger, to the target, and doesn't just affect an area.
Well, the GM ruled that, because of the specific circumstances, the spell would fail. The way he saw it, the lightning was shooting towards him, with him vanishing right before it hits him.
All that said, what is the actual rule on this? When a spell specifically targets a thing/creature, and then that thing/creature vanishes at the last instant, but stays within range of the spell, does the spell still activate? I can see this working for chain lightning, and other damaging spells, but what about spells like hold person?
This situation occurred while playing pathfinder, to be specific.