Sometimes they tend to swallow things the wrong way so they'd spit it out again and again til they find a more suitable angle for the food to be swallowed. The same goes when they're eating live bugs. The spitting is their way of killing and drowning non-aquatic live prey fast.