Passing strings between functions XMLHTTP.open

Discussion in 'Javascript' started by jerm, May 9, 2008.

  1. jerm

    jerm Guest

    Hi,

    I am using ajax to update a form. I call xmlHttp.open("GET", strURL,
    false).

    The problem is that strURL is a really long string and it seems that
    javascript craps out on this long string giving me an unspecified
    error. I decided to test my theory and created a generic function to
    pass over my url string and sure enough javascript dies with the same
    error. I figured one way around it was to split my string into an
    array and then join it up again but xmlHttp.open is not a method or
    object I wrote, so I cant easily manipulate it.

    Any thoughts on a way around this?

    Regards,
    Jeremiah
     
    jerm, May 9, 2008
    #1
    1. Advertising

  2. jerm

    Tom Cole Guest

    On May 9, 9:59 am, jerm <> wrote:
    > Hi,
    >
    > I am using ajax to update a form.  I call xmlHttp.open("GET", strURL,
    > false).
    >
    > The problem is that strURL is a really long string and it seems that
    > javascript craps out on this long string giving me an unspecified
    > error.  I decided to test my theory and created a generic function to
    > pass over my url string and sure enough javascript dies with the same
    > error.  I figured one way around it was to split my string into an
    > array and then join it up again but xmlHttp.open is not a method or
    > object I wrote, so I cant easily manipulate it.
    >
    > Any thoughts on a way around this?
    >
    > Regards,
    > Jeremiah


    Have you tried using POST as your method? Not sure it would help but
    you can also send the parameter string in the send method, rather than
    appending to the url and sending one huge url:

    xmlHttp.open("POST", "http://www.myserver.com/servlet/myServlet",
    true);
    xmlHttp.send("this=that&this2=that2");

    Just some things to think about. I have not run into a scenario where
    I was sending a url string longer than 255 characters, so I'm sorry I
    can't be of more assistance.
     
    Tom Cole, May 9, 2008
    #2
    1. Advertising

  3. jerm wrote:
    > I am using ajax to update a form. I call xmlHttp.open("GET", strURL,
    > false).
    >
    > The problem is that strURL is a really long string and it seems that
    > javascript craps out on this long string giving me an unspecified
    > error.


    Chances are that your crappy user agent and its API are the problem, not
    "javascript". For example, MSIE is known to support only 2083 characters
    per URI: http://support.microsoft.com/kb/208427

    > I decided to test my theory and created a generic function to
    > pass over my url string and sure enough javascript dies with the same
    > error.


    Which error?

    > I figured one way around it was to split my string into an
    > array and then join it up again but xmlHttp.open is not a method or
    > object I wrote, so I cant easily manipulate it.


    It would not help you anyway. The URI needs to be complete in an HTTP
    request. Read RFCs 1945 and 2616.

    > Any thoughts on a way around this?


    As you cannot prevent people from using crappy UAs, and you cannot expect
    the vendor of this particular crappy UA to get reasonable in no time, if
    that, make a POST request instead.


    PointedEars
    --
    Anyone who slaps a 'this page is best viewed with Browser X' label on
    a Web page appears to be yearning for the bad old days, before the Web,
    when you had very little chance of reading a document written on another
    computer, another word processor, or another network. -- Tim Berners-Lee
     
    Thomas 'PointedEars' Lahn, May 9, 2008
    #3
  4. jerm

    jerm Guest

    On May 9, 10:30 am, Thomas 'PointedEars' Lahn <>
    wrote:
    > jerm wrote:
    > > I am using ajax to update a form.  I call xmlHttp.open("GET", strURL,
    > > false).

    >
    > > The problem is that strURL is a really long string and it seems that
    > > javascript craps out on this long string giving me an unspecified
    > > error.

    >
    > Chances are that your crappy user agent and its API are the problem, not
    > "javascript".  For example, MSIE is known to support only 2083 characters
    > per URI:http://support.microsoft.com/kb/208427
    >
    > > I decided to test my theory and created a generic function to
    > > pass over my url string and sure enough javascript dies with the same
    > > error.

    >
    > Which error?
    >
    > > I figured one way around it was to split my string into an
    > > array and then join it up again but xmlHttp.open is not a method or
    > > object I wrote, so I cant easily manipulate it.

    >
    > It would not help you anyway.  The URI needs to be complete in an HTTP
    > request.  Read RFCs 1945 and 2616.
    >
    > > Any thoughts on a way around this?

    >
    > As you cannot prevent people from using crappy UAs, and you cannot expect
    > the vendor of this particular crappy UA to get reasonable in no time, if
    > that, make a POST request instead.
    >
    > PointedEars
    > --
    > Anyone who slaps a 'this page is best viewed with Browser X' label on
    > a Web page appears to be yearning for the bad old days, before the Web,
    > when you had very little chance of reading a document written on another
    > computer, another word processor, or another network. -- Tim Berners-Lee


    You are correct thomas, I ended up just breaking down my url and
    sending it in pieces. Thanks for your help!!!
    jerm
     
    jerm, May 9, 2008
    #4
    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. Steven Taylor
    Replies:
    3
    Views:
    466
    hibiki
    Apr 23, 2005
  2. Ben

    Strings, Strings and Damned Strings

    Ben, Jun 22, 2006, in forum: C Programming
    Replies:
    14
    Views:
    768
    Malcolm
    Jun 24, 2006
  3. Replies:
    10
    Views:
    596
    Barry Schwarz
    Apr 29, 2007
  4. Jason Morehouse

    xmlhttp.open "GET" during browser post?

    Jason Morehouse, Jan 2, 2005, in forum: Javascript
    Replies:
    2
    Views:
    141
    Jason Morehouse
    Jan 2, 2005
  5. yawnmoth

    Msxml*.XMLHTTP vs. Microsoft.XMLHTTP

    yawnmoth, Nov 7, 2006, in forum: Javascript
    Replies:
    11
    Views:
    398
    Matt Kruse
    Nov 9, 2006
Loading...

Share This Page