limit on number or size of javascript variables

Discussion in 'Javascript' started by Andy Fish, Aug 6, 2003.

  1. Andy Fish

    Andy Fish Guest

    Hi,

    I am in the process of designing a UI which has to be fairly sophisticated.
    There will be a number of list boxes and other controls, with pop-up windows
    to edit certain properties. It's the kind of thing I would normally have
    done in VB but I want it to be browser-based. I've only used javascript for
    trivial things before so this would be my first serious javascript
    development. I would like it to run on all reasonably recent browsers.

    The form starts with all the initial values being received from the server
    (presumably just by pre-initialised data structures). The user tinkers with
    it and when he is happy he presses 'submit' and the whole lot is submitted
    to the server (presumably as a form post). This would be a few kb of data,
    possibly 100 individual values but obviously in various data structures. I
    guess there would be a few hundred lines of javascript code to manipulate
    it.

    My question is, is there likely to be a problem with manipulating and
    sending this amount of data in Javascript. Sorry if this is a dumb question,
    but like I said, I only used javascript for tiny programs before, so I'm a
    bit unsure about its capabilities.

    Boastful replies of the form "I have an X thousand line javascript program
    that runs in all browsers and manipulates Y megabytes of data" would be most
    welcome :)

    Andy
     
    Andy Fish, Aug 6, 2003
    #1
    1. Advertising

  2. Andy Fish

    Grant Wagner Guest

    Steven Dilley wrote:

    > "Andy Fish" <> wrote in message
    > news:TpaYa.412$...
    > >
    > > I am in the process of designing a UI which has to be fairly

    > sophisticated.
    > > The form starts with all the initial values being received from the server
    > > (presumably just by pre-initialised data structures). The user tinkers

    > with
    > > it and when he is happy he presses 'submit' and the whole lot is submitted
    > > to the server (presumably as a form post). This would be a few kb of data,
    > > possibly 100 individual values but obviously in various data structures. I
    > > guess there would be a few hundred lines of javascript code to manipulate

    > it.
    > >
    > > My question is, is there likely to be a problem with manipulating and
    > > sending this amount of data in Javascript. Sorry if this is a dumb

    > question,
    > > but like I said, I only used javascript for tiny programs before, so I'm a
    > > bit unsure about its capabilities.

    >
    > Not a dumb question, but one based on a lack of background.
    > Javascript does not submit the data; the form does that.
    > The values are not javascript variables. In fact, your form does
    > not seem to need any Javascript at all, unless there is something you
    > haven't mentioned. Forms using the 'get' method are restricted to
    > (I think) 256 bytes, but the 'post' method can easily handle your few kb of
    > data.


    While I wouldn't suggest using a URI longer than about 256 characters, I did do
    some testing and this is what I found:

    There is a restriction on the length of a URI (including any parameters). In
    IE6SP1, the longest URI I could construct that would not be truncated was 2083
    bytes:

    <body onload="alert(window.location.href.length);">
    <script type="text/javascript">
    String.prototype.repeat = function(times) {
    return (new Array(times + 1)).join(this);
    }

    var s = "X";
    s = s.repeat(2003);

    document.write('<a href="hs~new.htm?p=' + s + 'Y">Test</a>');
    </script>

    Note that in my case, the original URL was 77 bytes, adding '?p=', the repeating
    X and the Y brought it to 2083. Anything longer then that and IE simply dropped
    everything after the '?' when navigating to the new page. Netscape 4.78, Mozilla
    1.5a and Opera 7.11 had no problems with longer URL, although I did not actually
    test to see if client-side JavaScript was capable of reading the passed values.

    I also didn't test the maximum length of URI that every browser can recognize,
    but it seems that the "big three" modern browsers can handle URI well in excess
    of 256 characters.

    Also be aware that someone else performed similar tests and got slightly
    different results (I believe they were able to construct a URI of only 2076
    bytes in IE).

    --
    | Grant Wagner <>
     
    Grant Wagner, Aug 6, 2003
    #2
    1. Advertising

  3. Andy Fish

    Andy Fish Guest

    OK, maybe I should be clearer about my requirements.

    The user will be maintaining a small set (2-10) of records. Because of the
    interrelationships between the records I don't want to commit changes each
    time the user navigates, so I want to store the data in an array of
    structures (sorry if this is not the correct javascript terminonogy). As the
    user navigates between the records the javascript will populate the fields
    on the screen and copy changes back into the array. When the user is happy,
    he presses the 'submit' button and all the changes are submitted,

    so the fields he sees on the screen aren't directly what gets posted to the
    server. I thought I might build all the results into an XML string and post
    it in a hidden text field or something, but I haven't really gone that far
    into the design yet.

    This is the way I would have done it in VB, but I'm not sure if this makes
    sense for javascript

    Thanks

    Andy

    "Steven Dilley" <steven.dilley.at.compuware.com> wrote in message
    news:3f316345$1@10.10.0.241...
    > "Andy Fish" <> wrote in message
    > news:TpaYa.412$...
    > >
    > > I am in the process of designing a UI which has to be fairly

    > sophisticated.
    > > The form starts with all the initial values being received from the

    server
    > > (presumably just by pre-initialised data structures). The user tinkers

    > with
    > > it and when he is happy he presses 'submit' and the whole lot is

    submitted
    > > to the server (presumably as a form post). This would be a few kb of

    data,
    > > possibly 100 individual values but obviously in various data structures.

    I
    > > guess there would be a few hundred lines of javascript code to

    manipulate
    > it.
    > >
    > > My question is, is there likely to be a problem with manipulating and
    > > sending this amount of data in Javascript. Sorry if this is a dumb

    > question,
    > > but like I said, I only used javascript for tiny programs before, so I'm

    a
    > > bit unsure about its capabilities.

    >
    > Not a dumb question, but one based on a lack of background.
    > Javascript does not submit the data; the form does that.
    > The values are not javascript variables. In fact, your form does
    > not seem to need any Javascript at all, unless there is something you
    > haven't mentioned. Forms using the 'get' method are restricted to
    > (I think) 256 bytes, but the 'post' method can easily handle your few kb

    of
    > data.
    > The number of individual values is not relevant. The only data structure
    > involved will be the Response object.
    >
    > You will need some server-side scripting to deal with the data sent by the
    > form (asp/jsp/php), and that can be of any size.
    >
    > --
    > Steve
    >
     
    Andy Fish, Aug 7, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mark
    Replies:
    2
    Views:
    351
  2. Kriston-Vizi Janos

    Maximum List size (item number) limit?

    Kriston-Vizi Janos, Jan 10, 2006, in forum: Python
    Replies:
    0
    Views:
    379
    Kriston-Vizi Janos
    Jan 10, 2006
  3. Kriston-Vizi Janos

    Maximum List size (item number) limit?

    Kriston-Vizi Janos, Jan 11, 2006, in forum: Python
    Replies:
    3
    Views:
    370
    Juho Schultz
    Jan 11, 2006
  4. Replies:
    1
    Views:
    1,130
    Victor Bazarov
    Jun 28, 2005
  5. jobs
    Replies:
    1
    Views:
    1,870
    Masudur
    Jul 15, 2007
Loading...

Share This Page