The entire unfortunate experience is due to two compounds, sodium alginate and calcium chloride. Sodium alginate is a long polymer already in a great deal of foods. It's used in pie fillings and milk shakes as a thickening agent. Its long chains of sugars stretch through the medium and tangle together, making the liquid around it thick. Sodium alginate is harvested from the long strands of kelp that grow in the Pacific ocean. An important part of the extraction process is removing all the calcium from the string of alginates. Why? This allows the strings to move freely and independently of each other. Calcium ions react with the sugar molecules in the chains and bind them together. This could harmlessly loop one string, which wouldn't make too much of a difference. But when two strings, and then more, get attached to each other, the entire string tangle fuses and solidifies into a gel.
Read the rest of the science at io9, but be warned that the author thinks this is a bad idea, so you may lose your appetite. Link -via Boing Boing