Ajax Flags Assignment

Incomplete -- got stuck on the portion where you add a certain number of flags at a time. For some reason, the templateHTML variable is undefined when I try to debug it. Not sure what I'm doing incorrectly.