textarea post 值被 url 中的 &= 截断

发布于 2024-12-28 00:06:18 字数 272 浏览 1 评论 0原文

我有一个文本区域,它将其值提交到 onkeypress 的 php 页面。问题是,如果您在文本区域中输入这样的网址:

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

接收文本区域数据的 php 页面会将 &othervalue=2 解释为文本区域的截止点,就好像 othervalue=2 是另一个后置变量一样收到。如果这没有意义,我会尝试以不同的方式解释它。有什么想法可以解决这个问题吗???

I have a textarea that submits its value to a php page onkeypress. the problem is, if you type a url like so into the 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. If this doesn't make sense I will try to explain it differently. Any ideas to get around this?????

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

望笑 2025-01-04 00:06:18
  1. 那是 GET 数据,而不是 POST 数据。
  2. 如果 value 应该等于 1&othervalue=2,则需要 urlencode 与符号,结果为 1%26othervalue%3D2
  1. That's GET data, not POST data.
  2. If value is supposed to equal 1&othervalue=2, you need to urlencode the ampersand, resulting in 1%26othervalue%3D2.
打小就很酷 2025-01-04 00:06:18

我假设您正在使用 ajax (因为您正在使用 onkeypress),请确保您始终正确转义数据。请参阅 encodeURIComponent

I assume you're using ajax (since you're using onkeypress), make sure you always escape your data properly. See encodeURIComponent

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文