Ajax string length limitation?

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

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

      

When the string length v

exceeds about 7000 bytes, it seems to drop. When less seems to work. Is my observation correct? Where does the restriction come from? From thin, Javascript or browser? I am using Google Chrome browser.

+3
javascript ajax


source to share


3 answers


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



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

+6


source to share


The limitation most likely comes from the browser. As per this discussion, you should try to keep your urls under about 2000 characters.



+1


source to share


There is a limit on the GET request based on the character bytes. If you're using ASCII, that's 256 characters including the URL itself . For UTF-8 this is almost half, because 1 utf character is 2 bytes long.

You won't have this problem in POST though.

-2


source to share







All Articles
Loading...
X
Show
Funny
Dev
Pics