3

I am getting a url from server with lot of data as query string

(E.g. http://www.test.com/?n=1,2,3,4,5,6,7,8.....100000) and I want to open it using window.open().

But the moment I pass the URL to window.open the url which gets gets truncated. After searching for sometime I could figure out that the maximum limit for URL is 2,083 characters(IE) so it passes PART of query string and truncates the rest..

How can I overcome this?

Please let me know if I need to provide more details.

Community
  • 1
  • 1
Shubh
  • 6,693
  • 9
  • 48
  • 83

3 Answers3

1

I think the only solution is to use POST instead of GET. Just use a form, instead of window.open. Please see this older answer: https://stackoverflow.com/a/17089124/907420

Community
  • 1
  • 1
roNn23
  • 1,532
  • 1
  • 15
  • 32
0

You could try URL shorteners, like goo.gl or bit.ly: https://goo.gl/

Speaking of programming, you could try to shorten your URL-s yourself, for the given example: Exact URL for your example, shorter by ~2000 characters. Where x..y is translated on server side as range(x, y) -> 1,2,3,4,5...100000 for x and y being 1 and 100000

0

If you want to stick with GET (and I would recommend that you use POST) you can try to compress the parameters. Instead of giving a huge number of parameters you create a javascript object holding the parameters, jsonfy it and you end up with a string that can be compressed and uncompressed again at the other end. Afterwards you can deserialize the JSON string and you have your parameters. Depending on the number of parameters it might still not be sufficient for a GET request.

But at the end a POST request is the best solution I think.

Sjoerd222888
  • 3,228
  • 3
  • 31
  • 64