[jQuery] jQuery usage to provide 'clean' JavaScript database strings

[jQuery] jQuery usage to provide 'clean' JavaScript database strings


I have recently had a problem with a web application that I'm doing
modifications to. I tracked it down to a few JavaScript AJAX
functions that were pulling options from a MySQL table and then
populating <option> values within a <select> form attribute. It turns
out that one of the table's fields contained an ampersand; that
ampersand broke all of the code.
I'm not sure exactly where the break occurred.. Firebug showed me
that the AJAX functions were returning a list of options to the JSP
servlet as it should have been. However when I started testing
javascript strings with ampersands in it, I noticed that there were
serious issues with the handling; at least in how FireBug displayed
the strings.
Anyway, I asked about this issue on a BBS that I'm a member of and one
of the JSP/JavaScript webapp developers that I know and respect
mentioned that using jQuery to set .text() on the element would
'clean' the string for me so that I don't have to worry about trying
to parse it and escape the ampersands or expand them to the
(ampersand)amp; element in the original string.
Unfortunately I'm unable to find any documentation on what methods to
use for this in the jQuery docs... Can anybody point me in the right
direction or give me some insight on how I would go about doing this?
I've never used this library to this point.
Thanks in advance.
+Damon Getsman
-=-=-=-
ITRx http://www.itrx-nd.com/
Programmer/System Administrator
-=-=-=-