Without getting into too much detail, since you are doing AJAX-based processing, note that AJAX requests always perform “postbacks” to the original page that is being rendered.
Since your modified page always outputs <HTML>-related tags, and since those tags aren't expected by the qcodo ajax response handler, you get an error.
It's pretty important to adhere to the .php and .tpl.php structure of qcodo if you're wanting to do AJAX-based processing, and not wrapping the top level .php (which is your QForm class instance) in anything else. If you're wanting to add <html> tags to your page, then this should be added to your .tpl.php file.
If you get a chance, I would recommend reading through the Examples site which should hopefully give you a pretty good overview on what these files are and how they get processed.