Hello, my name is***** and I have over 20 years of experience as a veterinarian. I am sorry to hear that your little one isn't feeling himself for the past couple of days, vomiting foam.
Vomiting foam simply is a mix of air and stomach/esophageal mucous made when he retches, it is not indicative of any disease process but tells us he is quite nauseous.
Is he running a fever (rectal temperature greater then 103F)?
Does he have a tense, painful abdomen with gentle pressure on his belly with your hands?
Vomiting and nausea can be due to stress, a change in diet, parasites, a viral or bacterial infection, eating something he should not (like a piece of a toy or too much table food), inflammatory bowel disease or even a food allergy. But it can also be related to metabolic organ disease (such kidney or liver disease or pancreatitis) due to organ wastes irritating the gut or an obstruction in the gastrointestinal tract.
How is he feeling otherwise? Is he bright and alert or does he seem very lethargic?
There are some things we can do to try and settle his stomach. To try and settle his stomach today you can try either:
1) Pepcid-ac (famotidine) at a dose of one quarter of a 10mg tablet per 5 to 10 pounds of body weight every 12 hours.
2) Prilosec (omeprazole) at a dose of one quarter of a 10mg tablet per 5 to 10 pounds of body weight every 24 hours.
These will reduce stomach acid and should help if this is related to simple nausea and gastrointestinal irritation. They can be given for several days if necessary.
I would wait to feed him any food for a good 6-12 hours after the acid reducers are started. This should help stop gut spasms and restore normal gut motility. Small amounts of water or clear broths like low salt chicken broth offered frequently are fine as he needs fluids. You can give him pedialyte to replace electrolytes too, though most dogs don't like the taste.
After his food fast if he isn't vomiting offer him a bland diet mix of 1/3 boiled, white skinless chicken, or very lean boiled, ground beef, all fats and juices drained off the meat, mixed with 2/3 boiled, plain white rice or pasta. Feed several small meals a day.
Once he feels better (no retching for 48 hours) start mixing in his regular dog food very slowly, less bland more regular with each day. It should take a week or so to convert him back.
If he is continuing to vomit, runs a fever or has a tense painful abdomen and is feeling poorly though it would be best that he see a veterinarian now as anything you give him orally will just come back up worsening his dehydration.
Best of luck with your fellow, please let me know if you have any further questions.