Damn Ampersands

ampersandI came across a bug with the jQuery serialize() method. The issue seemed random and I could not identify the source. Now I found it, and it makes total sense.

I have an application that tracks member information and added a feature to allow members to designate their carrier for their cell phone numbers to receive text messages from the club. With carrier information text messages can be sent via email without paying any third party or needing an SMS server.

AT&T.

Yes, AT&T was causing a problem in my application because I didn’t use &amp; for & in my <select> element option’s text. Upon submitting the form I expected the receiving page to only see the value assigned to each option, but no. Apparently the text of the selected option is also serialized and when that happens it confuses the & in the text/name for a post variable name. This resulted in the receiving page to get a text value instead of the numeric “value” represented by the AT&T value.

Lesson learned, and it makes sense. Hope this information helps someone else.

Ampersand image is from The Ampersand Blog,

The Ampersand Blog

This entry was posted in Geek. Bookmark the permalink.