Having cloudy water with foam on the surface usually means that your pool chemistry is imbalanced. So check it first and treat the water accordingly. If the chemicals are balanced, another common reason is a problem in the filtration system and possible air leakage. Check the article about
cleaning cloudy water
.