开发者

Sending ampersand in GET

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开发者_如何学Python&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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜