问题
This is my first question... I hope my problem doesn't look stupid...
html (any symbols are allowed) ---> javascript event ---> javascript function sends text to .php file using ajax method. Here is a problem:
when I use xmlhttp.open("GET","proceed.php?q="+encodeURIComponent(str),false); it works great for small texts (less than 1500 symbols)....
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.
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...
With a text over 1500 symbols there is no action at all (no viewable mistake, no nothing, just nothing happens).
Thank you.
回答1:
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.
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.
来源:https://stackoverflow.com/questions/7004593/phpajaxjavascript-encodeuricomponent-cuts-my-text-when-sending-to-the-server