php + ajax + javascript:encodeURIComponent在发送到服务器时会剪切我的文本 [英] php+ajax+javascript: encodeURIComponent cuts my text when sending to the server

查看:58
本文介绍了php + ajax + javascript:encodeURIComponent在发送到服务器时会剪切我的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的第一个问题...我希望我的问题不会显得愚蠢...

This is my first question... I hope my problem doesn't look stupid...

html(允许使用任何符号)---> javascript事件---> javascript函数使用ajax方法将文本发送到.php文件.这是一个问题:

html (any symbols are allowed) ---> javascript event ---> javascript function sends text to .php file using ajax method. Here is a problem:

当我使用 xmlhttp.open("GET","proceed.php?q =" + encodeURIComponent(str),false); 它适用于小文本(少于1500个符号)....

when I use xmlhttp.open("GET","proceed.php?q="+encodeURIComponent(str),false); it works great for small texts (less than 1500 symbols)....

如果我使用 xmlhttp.open("GET","proceed.php?q =" + str,false); 那么它可以使用任何长度,但是我必须小心使用特殊字符.

If I use xmlhttp.open("GET","proceed.php?q="+str,false); then it works for any length, but I have to be careful with special characters.

为什么encodingURIComponent不能处理大量文本(超过1500个字符,甚至只是简单的字母数字符号)?有什么想法吗?

Why doesn't encodeURIComponent work for a bigger amount of text (over ~1500 even just simple alphanumeric symbols)? Any ideas?

所以,问题出在这个字符串中(我已经测试了其余所有字符串).

So, the problem is in this string (I've tested all the rest).

顺便说一句,它在保加利亚西里尔字母上进行了测试...

BTW, it was tested on bulgarian cyrillic letters...

文本超过1500个符号根本没有任何动作(没有可见的错误,没有,什么都没有发生).

With a text over 1500 symbols there is no action at all (no viewable mistake, no nothing, just nothing happens).

谢谢.

推荐答案

URL的长度有许多限制.在IE中,URL的总长度,包括GET查询字符串,不得超过2,083个字符.服务器也可能施加限制.

There are a number of limits which you can hit with the length of a URL. In IE, the total length of the URL, including a GET query string, must not exceed 2,083 characters. The server might impose a limit, too.

因此,显然不是长串问题的encodeURIComponent本身.而是,编码结果比未编码的字符串长,这似乎足以使您达到我上面提到的限制之一.

So apparently it's not encodeURIComponent itself which has a problem with long strings. Rather, the encoded result is longer than the unencoded string, and that seems to be enough to make you hit one of the limits I mentioned above.

这篇关于php + ajax + javascript:encodeURIComponent在发送到服务器时会剪切我的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆