You can use either encodeURI or encodeURIComponent. The php manual states:
Decodes any %## encoding in the given string.
So whatever the encoding function encodes, all %## sequences are decoded. So you can use either one of the JavaScript functions to encode it.
edit:
(In kind-of response to Gumbo's answer, which he removed?)
php's urldecode also decodes + signs to spaces (because it implements a different standard). To make sure that no plus signs that are actually intended are decoded on the php side, just use encodeURIComponent to be sure. That encodes + to %2B, which is then again safe from php's urldecode.