views:

47

answers:

1

I have a drop box which is populated by information from a database. Some of the items have ampersands in them. When the drop box is changed, there is some ajax done, and this includes sending the info from the drop box in a GET. An ampersand in the name of the item from the drop box messes up the URL for the GET.

For example, here is a sample URL generated by the ajax:

http://www.website.com/getReports.cfm?date=05/07/2010&room=Visitors Office&system=Windows & Screens

The "Windows & Screens" item messes up the get, so what the receiving page gets is just "Windows " for the system variable.

What would be the best way to work around this issue without changing the database, in ColdFusion or Javascript?

+4  A: 

Your client-side code should be building the URL using the Javascript encodeURIComponent() routine. To use it, the code should encode the parameter names and values before gluing them together with the "?" and "&" characters in the URL.

Pointy