You can’t cast Ajani’s Influence without a target creature. If the target creature is an illegal target when Ajani’s Influence tries to resolve, the spell doesn’t resolve. You won’t look at the top five cards of your library.