The attack is always completely resolved before checking if anything is Knocked Out. Here's an example.
Let's say it's Gengar SF vs Skuntank SF, each with no damage counters. It's the Skuntank player's turn. He attaches two PlusPowers to Skuntank and attacks with Plunder.
First step. Any Trainers attached to the Defending Pokemon? No, so continue.
Next step. Do damage. Base damage is 60. Apply relevant effects - two PlusPowers increases damage to 80. Apply W/R: add 30 damage for Gengar's Darkness Weakness. Total damage is 110.
Now that the attack has finished, check to see if anything would be Knocked Out.
This is when Fainting Spell triggers - during the time the game checks for any Pokemon that would be Knocked Out after an attack has finished.
Going back to our example now. Skuntank's Plunder effect has finished. Are there any Pokemon that would be KOed from any damage taken? If yes, they are now KOed. Gengar has 0 remaining HP, so he would be Knocked Out. However, due to Ampharos's Poke-Body, Fainting Spell can't trigger (Gengar currently has 11 damage counters on it).
Once each Pokemon has been checked to see if it gets Knocked Out, then those Pokemon get Knocked Out. If the Active Pokemon was Knocked Out, it is replaced, then relevant between turns effects happen, and the opponent's turn begins.