For the case the javascript code generates DHTML, the HTML entities in code (such as input, textarea, buttons etc.) are not encoded. As a result they are shown as HTML elements.
I suggest to use "htmlspecialchars" function from phpjs.org 1 to solve this issue:
in the while loop:
list += "
" + keys[i] + "
:
" + htmlspecialchars(d[keys[i]]) + "
";
Regards, Beni