如何在Mootools中通过AJAX发送的数据中转义“+”?

I was building a simple web based calculator which takes equations from a HTML form, evaluates it on the server using PHP and sends the result back.

I am using Mootools to send the data via the req.send AJAX operation.

But, each time I have a '+' in an equation, it is not seen on the POST data the server gets.

Any ideas why this is happening and how I can work around it?

eg:

10 + 12 in HTML form is seen as 10 12 in the $_POST data.

The Mootools send command I am using is something like this with

<textarea name="equationTextArea">10+12</textarea>

req.send("eqn="+$('equationTextArea').value);

Upon submit, I see $_REQUEST['eqn'] as 10 12.

Try using the function encodeURIComponent over your text value. It, well.. uri encodes your text.

Your text most likely either need to be URLEncoded.

Set your form's encoding to multipart/form-data - this is an alternative to the default application/x-www-form-urlencoded and doesn't encode a space into a plus sign +.

Example from the w3.org reference:

<form action="http://example.com/cgi/handle"
   enctype="multipart/form-data"
   method="post">