Problem with prototype parameters

0 views
Skip to first unread message

César

unread,
Dec 23, 2009, 11:49:10 AM12/23/09
to Prototype & script.aculo.us
Hi I need some help:

When you enter a character (?) As parameter returns me empty. I put
this example:

In a text box with id = "name" entry = "Hi" and through this function:


function sendRequest() {
new Ajax.Request("contact.php",
{
method: 'post',
parameters: 'name='+$F('name'),
onCreate : function startLoading() {
$('respuesta').innerHTML= '<img src="images/sending.gif"
width="16" height="16" align="absmiddle">';
Form.Element.disable("Envia");
},
onComplete: function showResponse(req){
$('respuesta').innerHTML= req.responseText;
Form.Element.enable("Envia");
if(req.responseText == "success") {
$('mensaje_contacto').innerHTML= 'success';
}
}
});
}


I return "Hi" satisfactorily. But if I enter "Hi?" I returned empty.
It seems that if I enter (?) Occurs an error in the parameter section.
How can I solve this?. I hope your help. Thank you very much.

T.J. Crowder

unread,
Dec 23, 2009, 5:25:05 PM12/23/09
to Prototype & script.aculo.us
Hi,

You're supplying the parameters as a string, which means *you're*
taking responsibility for URL-encoding them correctly[1] -- but you're
not. I suggest letting Prototype handle the encoding, by supplying
your parameters as an object:

parameters: {name: $F('name')},

[1] http://prototypejs.org/api/ajax/options

HTH,
--
T.J. Crowder
Independent Software Consultant
tj / crowder software / com
www.crowdersoftware.com

Reply all
Reply to author
Forward
0 new messages