Hey, I haz a question that I think was already asked but I'm too lazy to look around xD

If a pokemon participates in a battle that is still ongoing, and it has fainted, can you evolve it and use that battle as exp?