Ajax字符串长度限制? [英] Ajax string length limit?

查看:361
本文介绍了Ajax字符串长度限制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以添加到ajax的url的参数长度是否有限制?我在Ruby上使用Thin服务器,并以这种格式从Web浏览器发出ajax请求:

Is there a limit to the length of the parameter that be can added to the url for ajax? I am using Thin server on Ruby, and did an ajax request from the web browser in this format:

io=new XMLHttpRequest();
io.open("GET","http://localhost:3000&v="+encodeURIComponent(JSON.stringify(v)),true);

当字符串 v 的长度超过大约7000字节,似乎崩溃了。当更少时,似乎工作。我的观察是对的吗?限制来自哪里?从Thin,Javascript还是浏览器?我使用谷歌Chrome浏览器。

When the length of the string v exceeds about 7000 bytes, it seems to crash. When less, it seems to work. Is my observation right? Where is the restriction coming from? From Thin, Javascript, or the browser? I use Google Chrome browser.

推荐答案


参数的长度是否有限制添加到ajax的URL?

Is there a limit to the length of the parameter that can added to the url for ajax?

是的,如果您使用的是GET请求,则有一个限制,这取决于客户端浏览器。而这个限制与AJAX无关。对于IE,IIRC大概是4K,但事情可能已经发生了变化。但无论如何都有一个限制。如果你不想被限制,你应该使用POST。

Yes, if you are using a GET request there's a limit which will depend on the client browser. And this limit has nothing to do with AJAX. IIRC it was around 4K for IE but things might have changed. But in any case there's a limit. If you don't want to be limited you should use POST.

这篇关于Ajax字符串长度限制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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