1

I implemented an http server using javascript and Node.js.

for some reason when the user fills in a form, let's say his full name, on the server side i get what the user filled in but.. i get "+" between all the words instead of " ".

this is the client side:

<form id="register" action="/register" method="post">
<input type="text" id="reg_usname" class="input" name="username" required autofocus/>
<form /> 

this is the server side:

var username=request.parameters['username'];//request is an http request that is         returned

I have no idea why it is that way.

I can just simply replace all the "+" to " " but it seems that there is a smarter way to fix the problem.

1
  • 1
    Have you considering utilizing Express.JS or at least the lower-level connect framework to handle the http parsing? You can be a opinionated as you like on top of connect layet. Commented Feb 3, 2012 at 15:46

1 Answer 1

1

The data you are passing back to the server is being URL Encoded.

Here's a the RFC spec from the people who wrote it that explains how & why.

The JavaScript functions you can use to encode/decode can be found on this Mozilla Developer Network page.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.