Loading URL contents into a variable

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Scott Orsburn

    #1

    Loading URL contents into a variable

    Is there a way to load the contents returned from a URL into a
    JavaScript variable? Suppose a user picks an option from a popup list.
    I want to pass that choice in a URL to a script on a server that runs a
    query on a database. The value is returned from the URL and is
    populated in a JavaScript variable. Something like:

    function LookupFunc(Test String)
    {
    TheResult = script.loadValu eFrom =
    "http://dbserver/LookupScript.ph p?TheValue=" + TestString;

    alert(TheResult );
    }

    The goal is that I can lookup values "on the fly" rather than trying to
    accommodate the choices before hand.


    __
    Scott Orsburn
    Kaomso


    I'm not clever enough to think of a cool signature.

  • Michael Winter

    #2
    Re: Loading URL contents into a variable

    On Wed, 24 Nov 2004 08:47:36 -0500, Scott Orsburn
    <scottso_no@spa m_maclaunch.com > wrote:
    [color=blue]
    > Is there a way to load the contents returned from a URL into a
    > JavaScript variable?[/color]

    See the FAQ (<URL:http://jibbering.com/faq/>).

    [snip]
    [color=blue]
    > __[/color]

    The convention on Usenet is that signatures begin dash-dash-space (-- ).
    This helps news readers identify and format signatures, and remove them
    automatically when a user selects "Reply".

    [snip]

    Mike

    --
    Michael Winter
    Replace ".invalid" with ".uk" to reply by e-mail.

    Comment

    • Martin Honnen

      #3
      Re: Loading URL contents into a variable



      Scott Orsburn wrote:
      [color=blue]
      > Is there a way to load the contents returned from a URL into a
      > JavaScript variable? Suppose a user picks an option from a popup list.
      > I want to pass that choice in a URL to a script on a server that runs a
      > query on a database. The value is returned from the URL and is
      > populated in a JavaScript variable. Something like:
      >
      > function LookupFunc(Test String)
      > {
      > TheResult = script.loadValu eFrom =
      > "http://dbserver/LookupScript.ph p?TheValue=" + TestString;
      > alert(TheResult );
      > }
      >
      > The goal is that I can lookup values "on the fly" rather than trying to
      > accommodate the choices before hand.[/color]

      With a growing range of browsers (IE5+/Win, Netscape 6/7, Mozilla,
      Firefox, Safari 1.2, Opera 7.6x when it comes out) you can do that,
      however the interfaces are geared towards sending and receiving XML. And
      of course it might make sense to load asynchronously so you will need an
      event handler set up to handle the received data.
      See
      http://www.faqts.com/knowledge_base/.../17226/fid/616
      and


      For IE/Win there is also the download behaviour as described here:
      http://www.faqts.com/knowledge_base/...d/1268/fid/126

      --

      Martin Honnen
      http://JavaScript.FAQTs.com/

      Comment

      • Scott Orsburn

        #4
        Re: Loading URL contents into a variable

        Mike,

        thank you for your unsolicited advise about Usenet convention. If I
        might offer some of my own? Referring a poster to a vague URL is not
        helpful. Pointing to a relevant document from a site is helpful. If I
        wanted a generic JavaScript resource site I can find those on my own.


        Michael Winter wrote:
        [color=blue]
        > On Wed, 24 Nov 2004 08:47:36 -0500, Scott Orsburn
        > <scottso_no@spa m_maclaunch.com > wrote:
        >[color=green]
        >> Is there a way to load the contents returned from a URL into a
        >> JavaScript variable?[/color]
        >
        >
        > See the FAQ (<URL:http://jibbering.com/faq/>).
        >
        > [snip]
        >[color=green]
        >> __[/color]
        >
        >
        > The convention on Usenet is that signatures begin dash-dash-space (--
        > ). This helps news readers identify and format signatures, and remove
        > them automatically when a user selects "Reply".
        >
        > [snip]
        >
        > Mike
        >[/color]

        Comment

        • Scott Orsburn

          #5
          Re: Loading URL contents into a variable

          My apologies. This was supposed to be in repsonse to Michael Winter's post.

          Martin, the links you provided were the sort of thing I was looking
          for. This gives me a good starting point. Thank you.

          --
          Scott Orsburn
          Kaomso



          Scott Orsburn wrote:
          [color=blue]
          > Mike,
          >
          > thank you for your unsolicited advise about Usenet convention. If I
          > might offer some of my own? Referring a poster to a vague URL is not
          > helpful. Pointing to a relevant document from a site is helpful. If
          > I wanted a generic JavaScript resource site I can find those on my own.[/color]

          Comment

          • Michael Winter

            #6
            Re: Loading URL contents into a variable

            On Wed, 24 Nov 2004 10:07:47 -0500, Scott Orsburn
            <scottso_no@spa m_maclaunch.com > wrote:
            [color=blue]
            > thank you for your unsolicited advise about Usenet convention.[/color]

            You're welcome.

            How about some more: please don't top-post to this group.
            [color=blue]
            > If I might offer some of my own? Referring a poster to a vague URL is
            > not helpful.[/color]

            The idea is to refer them to a document that might be useful, not only
            now, but in the future too. My apologies if you don't appreciate that,
            however if you're too lazy (or simply unwilling) to spend the two minutes
            (maximum) necessary to read the list of questions in the Quick Answers
            section, fair enough, but frankly that isn't my concern.
            [color=blue]
            > Pointing to a relevant document from a site is helpful.[/color]

            So I fail to see the problem.
            [color=blue]
            > If I wanted a generic JavaScript resource site I can find those on my
            > own.[/color]

            Most of them are full of bad advice and code that hasn't undergone any
            form of review. If that's what you want, be my guest.

            [snip]

            Hmmm. I must be stressed today.

            Mike

            --
            Michael Winter
            Replace ".invalid" with ".uk" to reply by e-mail.

            Comment

            • Scott Orsburn

              #7
              Re: Loading URL contents into a variable

              Michael (Usenet police),

              does this message conform?
              [color=blue]
              > The idea is to refer them to a document that might be useful, not
              > only now, but in the future too. My apologies if you don't appreciate
              > that, however if you're too lazy (or simply unwilling) to spend the
              > two minutes (maximum) necessary to read the list of questions in the
              > Quick Answers section, fair enough, but frankly that isn't my concern.[/color]


              Lazy huh? I had a pretty specific question. You gave a pretty general
              site. There's no need to post if you don't have an answer. I tend to
              be pretty resourceful and don't need a sermon from you.
              [color=blue]
              > Most of them are full of bad advice and code that hasn't undergone
              > any form of review. If that's what you want, be my guest.[/color]

              Thanks for that heads up!

              I'll wait for your reply to this, then my discussion with you is done as
              this does not pertain to my question at all.


              --
              Scott Orsburn
              Kaomso


              I'm not clever enought to think of a cool signature.

              Comment

              • Andrew Thompson

                #8
                Re: Loading URL contents into a variable

                On Wed, 24 Nov 2004 11:33:13 -0500, Scott Orsburn wrote:
                [color=blue]
                > does this message conform?[/color]

                Conform to the theory that you are a dolt for not reading the
                entirety of the resource to which he linked?

                Yes.

                --
                Andrew Thompson
                http://www.PhySci.org/codes/ Web & IT Help
                http://www.PhySci.org/ Open-source software suite
                http://www.1point1C.org/ Science & Technology
                http://www.LensEscapes.com/ Images that escape the mundane

                Comment

                • Michael Winter

                  #9
                  Re: Loading URL contents into a variable

                  On Wed, 24 Nov 2004 11:33:13 -0500, Scott Orsburn
                  <scottso_no@spa m_maclaunch.com > wrote:
                  [color=blue]
                  > Michael (Usenet police),[/color]

                  Perhaps you don't realise that some take offense to people that don't
                  follow convention. Personally, I couldn't care less. It's frustrating when
                  people don't listen (and I thank you for correcting both previous posts),
                  but I'll live.

                  The advice was for your benefit. You seem to have trouble accepting the
                  fact that I *am* trying to help you.
                  [color=blue][color=green]
                  >> The idea is to refer them to a document that might be useful, not only
                  >> now, but in the future too. My apologies if you don't appreciate that,
                  >> however if you're too lazy (or simply unwilling) to spend the two
                  >> minutes (maximum) necessary to read the list of questions in the Quick
                  >> Answers section, fair enough, but frankly that isn't my concern.[/color]
                  >
                  > Lazy huh?[/color]

                  It would appear so.
                  [color=blue]
                  > I had a pretty specific question.[/color]

                  That you did.
                  [color=blue]
                  > You gave a pretty general site. There's no need to post if you don't
                  > have an answer.[/color]

                  Why post an answer when I can refer to a site that does? That's the point
                  of the FAQ, and the reason why you should attempt to find and read one
                  before posting to a group. It would have made your post, and this
                  argument, completely unnecessary.
                  [color=blue]
                  > I tend to be pretty resourceful and don't need a sermon from you.[/color]

                  So again, I question why there is this problem.

                  [snip]
                  [color=blue]
                  > I'll wait for your reply to this, then my discussion with you is done as
                  > this does not pertain to my question at all.[/color]

                  Good. I hate being drawn into flame wars.

                  Mike

                  --
                  Michael Winter
                  Replace ".invalid" with ".uk" to reply by e-mail.

                  Comment

                  • Scott Orsburn

                    #10
                    Re: Loading URL contents into a variable

                    [color=blue]
                    >Conform to the theory that you are a dolt for not reading the
                    >entirety of the resource to which he linked?
                    >[/color]
                    Great so I finish up with Mike, now I get to start with you.

                    Andrew, let me be perfectly plain here. Mike knew where the answer was
                    and pointed me to a high-level site containing it. This did not address
                    the question I had. If he felt the need to repsond to my post then what
                    he should have done is pointed me to the actual page--not the site. His
                    reply should have been this:



                    Not:



                    The former is helpful. The latter is not. Mike's line of thinking
                    would point me to an entire JavaScript manual even if all I were looking
                    for were the syntax for accessing a form value. Again, this sort of
                    advise can go without saying. If you have a link to an example, then
                    post. If you have a link to a site, then don't. We can all get that far.

                    You, like Mike don't need to post just to post. It's okay.


                    --
                    Scott Orsburn
                    Kaomso


                    I'm not clever enought to think of a cool signature.

                    Comment

                    • Dr John Stockton

                      #11
                      Re: Loading URL contents into a variable

                      JRS: In article <co23dm0rmq@ene ws4.newsguy.com >, dated Wed, 24 Nov 2004
                      08:47:36, seen in news:comp.lang. javascript, Scott Orsburn <scottso_no@s
                      pam_maclaunch.c om> posted :[color=blue]
                      >Is there a way to load the contents returned from a URL into a
                      >JavaScript variable? Suppose a user picks an option from a popup list.
                      >I want to pass that choice in a URL to a script on a server that runs a
                      >query on a database. The value is returned from the URL and is
                      >populated in a JavaScript variable. Something like:
                      >
                      > function LookupFunc(Test String)
                      > {
                      > TheResult = script.loadValu eFrom =
                      >"http://dbserver/LookupScript.ph p?TheValue=" + TestString;
                      >
                      > alert(TheResult );
                      > }
                      >
                      >The goal is that I can lookup values "on the fly" rather than trying to
                      >accommodate the choices before hand.[/color]

                      If you wish to ask questions in this newsgroup *and* like the responses,
                      you need to look at the *whole* of the regularly-posted newsgroup FAQ
                      first; you need to honour the agreed Usenet conventions, as there
                      described and linked, and, for each question, you need to consider
                      whether the answer is already in the newsgroup FAQ. Otherwise, you will
                      find the experience unsatisfactory.

                      You also need to compose your question with care; many of those here do
                      not have English as their native language and, of them, many have been
                      taught it better than you or I have. You have, in particular, mingled
                      the expression of your need with the way that you think that it can be
                      satisfied.

                      Your need is, it seems, for a user action to cause your code to question
                      a server and then for your code to be able to access its answer.

                      FAQ 4.34 appears to answer the first part of that; but it is not of
                      itself clear as to how the response received can be accessed by the
                      script on the questioning page. Probably the link shows that.

                      --
                      © John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
                      <URL:http://www.jibbering.c om/faq/> JL/RC: FAQ of news:comp.lang. javascript
                      <URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
                      <URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.

                      Comment

                      • Scott Orsburn

                        #12
                        Re: Loading URL contents into a variable

                        [color=blue]
                        >If you wish to ask questions in this newsgroup *and* like the responses,
                        >you need to look at the *whole* of the regularly-posted newsgroup FAQ
                        >first; you need to honour the agreed Usenet conventions, as there
                        >described and linked, and, for each question, you need to consider
                        >whether the answer is already in the newsgroup FAQ. Otherwise, you will
                        >find the experience unsatisfactory.
                        >
                        >[/color]
                        It seems that I am the odd man out here. I tried tried to participate
                        in the newsgroup with a straight forward question and got more responses
                        concerning form and practices of Usenet than the question I posed. I
                        suppose that failure to study the guidlines of how to post a message
                        warrants a rebuffing from other posters. I understand now.

                        Before I posted this message I did some quick searching to find the
                        documents that describe the Usenet conventions so that in the future I
                        will be sure not to offend anyone and to be sure to do my homework
                        before posting a question. The search was not so productive. It would
                        seem that this dicussion network is really a subculture of the
                        Internet. Please point me to a FAQ addressing these issues if I am wrong.

                        I failed to discover a FAQ on a site called jibbering.com pertaining to
                        JavaScript on my own, so chances are I have not found a FAQ for how to
                        post messages to a discussion group. Your help is appreciated.

                        --
                        Scott Orsburn

                        scottso_no@spam _maclaunch.com

                        Comment

                        • Michael Winter

                          #13
                          Re: Loading URL contents into a variable

                          On Mon, 29 Nov 2004 15:03:06 -0500, Scott Orsburn
                          <scottso_no@spa m_maclaunch.com > wrote:

                          [snip]
                          [color=blue]
                          > Please point me to a FAQ addressing [posting] issues [...][/color]

                          RFC 1855 - Netiquette Guidelines (*LONG*)
                          <URL:http://www.faqs.org/rfcs/rfc1855.html>

                          comp.lang.javas cript FAQ, sections 2.1-5
                          <URL:http://jibbering.com/faq/#FAQ2_1>

                          comp.lang.javas cript FAQ Notes - Posting Questions and Replies to
                          comp.lang.javas cript, and linked resources
                          <URL:http://www.jibbering.c om/faq/faq_notes/pots1.html>


                          Be warned that RFC 1855 covers many issues. The most appropriate sections
                          for Usenet (NetNews in the document) are 3.1.1 - General Guidelines for
                          mailing lists and NetNews and 3.1.3 - NetNews Guidelines. However, also
                          read 2.1.1 - [User Guidelines] For mail.

                          [snip]

                          Mike

                          --
                          Michael Winter
                          Replace ".invalid" with ".uk" to reply by e-mail.

                          Comment

                          • Dr John Stockton

                            #14
                            Re: Loading URL contents into a variable

                            JRS: In article <cofv9e01ffh@en ews4.newsguy.co m>, dated Mon, 29 Nov
                            2004 15:03:06, seen in news:comp.lang. javascript, Scott Orsburn
                            <scottso_no@spa m_maclaunch.com > posted :

                            Please configure an adequately informative attribution, as is the Usenet
                            custom.
                            [color=blue][color=green]
                            >>If you wish to ask questions in this newsgroup *and* like the responses,
                            >>you need to look at the *whole* of the regularly-posted newsgroup FAQ
                            >>first; you need to honour the agreed Usenet conventions, as there
                            >>described and linked, and, for each question, you need to consider
                            >>whether the answer is already in the newsgroup FAQ. Otherwise, you will
                            >>find the experience unsatisfactory.
                            >>
                            >>[/color]
                            >It seems that I am the odd man out here. I tried tried to participate
                            >in the newsgroup with a straight forward question and got more responses
                            >concerning form and practices of Usenet than the question I posed. I
                            >suppose that failure to study the guidlines of how to post a message
                            >warrants a rebuffing from other posters. I understand now.[/color]

                            Correct.
                            [color=blue]
                            >Before I posted this message I did some quick searching to find the
                            >documents that describe the Usenet conventions so that in the future I
                            >will be sure not to offend anyone and to be sure to do my homework
                            >before posting a question. The search was not so productive. It would
                            >seem that this dicussion network is really a subculture of the
                            >Internet. Please point me to a FAQ addressing these issues if I am wrong.
                            >
                            >I failed to discover a FAQ on a site called jibbering.com pertaining to
                            >JavaScript on my own, so chances are I have not found a FAQ for how to
                            >post messages to a discussion group. Your help is appreciated.[/color]

                            AIUI, jibbering is not 100% reliable.

                            But you were referred to the regularly-posted newsgroup FAQ. The
                            posting of that is reliable, currently; it appears, in two parts, on Mon
                            Wed Fri, so you should have seen it when you perused the newsgroup
                            before posting to it. It contains the meat, but not the decoration, of
                            what is at jibbering.

                            It contains guidance on posting to this newsgroup, and links to accepted
                            Usenet-wide authorities.

                            It does not, admittedly, inform you that Michael Winter's advice should
                            always be considered carefully and /in toto/. That you are expected to
                            deduce for yourself.

                            As it is, you are now forever, or at least until we forget, noted as
                            being a misfit.

                            --
                            © John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
                            <URL:http://www.jibbering.c om/faq/> JL/RC: FAQ of news:comp.lang. javascript
                            <URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
                            <URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.

                            Comment

                            • Scott Orsburn

                              #15
                              Re: Loading URL contents into a variable

                              >[color=blue]
                              >
                              >Please configure an adequately informative attribution, as is the Usenet
                              >custom.
                              >
                              >[/color]
                              John, I'm not sure what you're responding to here.
                              [color=blue][color=green]
                              >>It seems that I am the odd man out here. I tried tried to participate
                              >>in the newsgroup with a straight forward question and got more responses
                              >>concerning form and practices of Usenet than the question I posed. I
                              >>suppose that failure to study the guidlines of how to post a message
                              >>warrants a rebuffing from other posters. I understand now.
                              >>
                              >>[/color]
                              >
                              >Correct.
                              >
                              >[/color]
                              Thanks.
                              [color=blue]
                              > AIUI, jibbering is not 100% reliable.
                              >[/color]
                              Interesting note. Those who have cited it pass it as the authoritative
                              FAQ for this group. I have not yet come to the same conclusion as you
                              but I will be looking. Thanks again.
                              [color=blue]
                              >But you were referred to the regularly-posted newsgroup FAQ. The
                              >posting of that is reliable, currently; it appears, in two parts, on Mon
                              >Wed Fri, so you should have seen it when you perused the newsgroup
                              >before posting to it. It contains the meat, but not the decoration, of
                              >what is at jibbering.
                              >
                              >[/color]
                              Another failing on my part. Posting to Usenet has the potential to be
                              more trouble than its worth with all the preliminary steps involved
                              with being a responsible poster. This thread has most definately taught
                              me that its form, then substance that counts.
                              [color=blue]
                              >As it is, you are now forever, or at least until we forget, noted as
                              >being a misfit.
                              >
                              >
                              >[/color]
                              All right then. I'm not sure why you included this. My previous post
                              has conceded to being green (new) with regard to Usenet. I never
                              estimated the importance placed on the way a post is formed or the
                              content of it. But if such is the case, I guess I'm a misfit.

                              Comment

                              Working...