RcoderNY
RcoderNY

Reputation: 1764

How to send HTML code in an http POST request?

I am an sending a HTTP POST request from a Google Web Toolkit app to a php script. The content-type is "application/x-www-form-urlencoded" right now so I can send variables to php and use $_POST[] in php but I don't think I can properly send HTML markup inside one of the variables.

Here's what I have: post_data = var1=true&var2=true$html="HTML MARKUP HERE"

When doing it this way barely any of the html comes through to php in the $_POST['html'] variable. What is the proper method to accomplish sending html markup in a POST variable. Thanks.

Upvotes: 4

Views: 13306

Answers (1)

Matt Ball
Matt Ball

Reputation: 359966

Percent-encode the query parameter. In JavaScript, you can use the encodeURIComponent function.

Upvotes: 10

Related Questions