The nymphs, called spittlebugs, make the foam, although it isn't actually spittle.[1]
The spray is usually more than enough to deter any hungry predators and make them go away.[1]
Insect blood, called hemolymph.[1]