I'm pretty sure the .val()
returns the string perfectly, but that the AJAX module does some URL encoding on your data. I encountered this problem somewhere too... Hold on, I'll try to find the solution I used back then.
Edit:
This is the piece of code that would serialize a form for me:
var data = '';
for(var i = 0; frm.elements[i] != undefined; i++) {
data += frm.elements[i].name + '=' + encodeURIComponent(frm.elements[i].value);
if(frm.elements[i + 1] != undefined) data += '&';
}
in which frm
is your form, obviously. You'll probably only need the encodeURIComponent()
-function if you're only submitting the lone string.