简体   繁体   English

url中的textarea帖子值被&=切断

[英]textarea post value getting cut off by &= in url

I have a textarea that submits its value to a php page onkeypress. 我有一个textarea,它将其值提交给onkeypress的php页面。 the problem is, if you type a url like so into the textarea: 问题是,如果您在textarea中键入如下网址:

http://website.com/index.php?value=1&othervalue=2

the php page receiving the textarea data interprets &othervalue=2 to be the cutoff point for the text area as if othervalue=2 was another post variable it is supposed to receive. 接收textarea数据的php页面将&othervalue = 2解释为文本区域的临界点,就好像othervalue = 2是它应该接收的另一个发布变量一样。 If this doesn't make sense I will try to explain it differently. 如果这没有意义,我将尝试以不同的方式解释它。 Any ideas to get around this????? 有什么想法可以解决这个问题?????

  1. That's GET data, not POST data. 那是GET数据,而不是POST数据。
  2. If value is supposed to equal 1&othervalue=2 , you need to urlencode the ampersand, resulting in 1%26othervalue%3D2 . 如果value应该等于1&othervalue=2 ,那么您需要对&符号进行urlencode ,从而得到1%26othervalue%3D2

I assume you're using ajax (since you're using onkeypress), make sure you always escape your data properly. 我假设您使用的是ajax(因为您使用的是onkeypress),请确保始终正确地转义数据。 See encodeURIComponent 参见encodeURIComponent

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM