AJAX problem

Discussion in 'Javascript' started by Bruce A. Julseth, Jan 13, 2009.

  1. I have the following code snippet:

    function LoadLists() {
    makerequest('SelectMonth.htm','Mo');
    makerequest('SelectDay.htm','Da');
    makerequest('SelectYear.htm','Yr');
    }

    //-->
    </script>

    <body onload="LoadLists()">
    <form name="form1" id="form1" method="post" action="">
    <label for="select">Year</label>
    <div id='Yr'> </div>
    <label for="select">Month</label>
    <div id='Mo'> </div>
    <label for="select">Day</label>
    <div id='Da'> </div>
    </form>
    </body>

    Only the last call in LoadList() is in the web page when it is displayed. I
    can make one of the other calls the last call and it will be displayed. The
    Select???.htm's contain <select><option> html.
    Bruce A. Julseth, Jan 13, 2009
    #1
    1. Advertising

  2. Bruce A. Julseth meinte:
    > I have the following code snippet:


    It /definitely/ is a snippet.

    > function LoadLists() {
    > makerequest('SelectMonth.htm','Mo');
    > makerequest('SelectDay.htm','Da');
    > makerequest('SelectYear.htm','Yr');
    > }
    >
    > //-->
    > </script>
    >
    > <body onload="LoadLists()">
    > <form name="form1" id="form1" method="post" action="">
    > <label for="select">Year</label>
    > <div id='Yr'> </div>
    > <label for="select">Month</label>
    > <div id='Mo'> </div>
    > <label for="select">Day</label>
    > <div id='Da'> </div>
    > </form>
    > </body>
    >
    > Only the last call in LoadList() is in the web page when it is displayed. I
    > can make one of the other calls the last call and it will be displayed. The
    > Select???.htm's contain <select><option> html.


    Im pretty sure the error is in line 7.

    HTH, Gregor
    Gregor Kofler, Jan 13, 2009
    #2
    1. Advertising

  3. "Gregor Kofler" <> wrote in message
    news:Fn8bl.138$...
    > Bruce A. Julseth meinte:
    >> I have the following code snippet:

    >
    > It /definitely/ is a snippet.
    >
    >> function LoadLists() {
    >> makerequest('SelectMonth.htm','Mo');
    >> makerequest('SelectDay.htm','Da');
    >> makerequest('SelectYear.htm','Yr');
    >> }
    >>
    >> //-->
    >> </script>
    >>
    >> <body onload="LoadLists()">
    >> <form name="form1" id="form1" method="post" action="">
    >> <label for="select">Year</label>
    >> <div id='Yr'> </div>
    >> <label for="select">Month</label>
    >> <div id='Mo'> </div>
    >> <label for="select">Day</label>
    >> <div id='Da'> </div>
    >> </form>
    >> </body>
    >>
    >> Only the last call in LoadList() is in the web page when it is displayed.
    >> I
    >> can make one of the other calls the last call and it will be displayed.
    >> The
    >> Select???.htm's contain <select><option> html.

    >
    > Im pretty sure the error is in line 7.
    >
    > HTH, Gregor


    Thanks for the response. Line 7 is the standard comment end for JavaScript.
    On your suggestion, I took the comment out. Didn't change anything? Here is
    the makerequest function. It's right out of the book, "Beginning Ajax with
    PHP." It seems to work in all the book examples.

    function makerequest(serverPage, objID) {

    var obj = document.getElementById(objID);
    xmlhttp.open("GET", serverPage);
    xmlhttp.onreadystatechange = function() {
    if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
    obj.innerHTML = xmlhttp.responseText;
    }
    }
    xmlhttp.send(null);
    }
    Bruce A. Julseth, Jan 13, 2009
    #3
  4. On Tue, 13 Jan 2009 17:31:33 -0500, Bruce A. Julseth wrote:

    > "Gregor Kofler" <> wrote in message
    > news:Fn8bl.138$...
    >> Bruce A. Julseth meinte:
    >>> I have the following code snippet:

    >>
    >> It /definitely/ is a snippet.
    >>


    [ Code Snipped ]

    >>
    >> Im pretty sure the error is in line 7.
    >>
    >> HTH, Gregor

    >
    > Thanks for the response. Line 7 is the standard comment end for
    > JavaScript. On your suggestion, I took the comment out. Didn't change
    > anything? Here is the makerequest function. It's right out of the book,
    > "Beginning Ajax with PHP." It seems to work in all the book examples.
    >
    > function makerequest(serverPage, objID) {
    >
    > var obj = document.getElementById(objID); xmlhttp.open("GET",
    > serverPage);
    > xmlhttp.onreadystatechange = function() {
    > if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
    > obj.innerHTML = xmlhttp.responseText;
    > }
    > }
    > xmlhttp.send(null);
    > }


    Gregor's comment was a more-or-less standard response when one doesn't
    show enough code to be useful. In this case, your original snipping did
    not contain the section that was in error.

    (And using <!-- //--> with Javascript went obsolete about 10 years ago or
    so. Its only standard by people who don't know why they were used and
    why not to. They part of my list on how to recognize bad Javascript.)

    I would recommend and entirely different approach anyways. Since you are
    -already- using php to generate page content, generate the ENTIRE page
    using PHP and serve it. Javascript should [almost] always be an
    ENHANCEMENT to a page, not a requirement.

    > makerequest('SelectMonth.htm','Mo');


    Secondly, if you are only loading html fragments, as opposed to an entire
    page, I would not use the extension '.htm' Personally, I'd use '.txt'.

    You still have not shown enough context to allow anyone to answer your
    question. Posting a link would be a Good Idea(tm).
    Jeremy J Starcher, Jan 13, 2009
    #4
  5. Bruce A. Julseth wrote:
    > "Gregor Kofler" wrote:
    >> Bruce A. Julseth meinte:
    >>> function LoadLists() {
    >>> makerequest('SelectMonth.htm','Mo');
    >>> makerequest('SelectDay.htm','Da');
    >>> makerequest('SelectYear.htm','Yr');
    >>> }
    >>>
    >>> //-->
    >>> </script>
    >>>
    >>> <body onload="LoadLists()">
    >>> <form name="form1" id="form1" method="post" action="">


    The form might not need a name or an ID.

    >>> <label for="select">Year</label>
    >>> <div id='Yr'> </div>
    >>> <label for="select">Month</label>
    >>> <div id='Mo'> </div>
    >>> <label for="select">Day</label>
    >>> <div id='Da'> </div>
    >>> </form>
    >>> </body>
    >>>
    >>> Only the last call in LoadList() is in the web page when it is displayed.
    >>> I can make one of the other calls the last call and it will be displayed.
    >>> The Select???.htm's contain <select><option> html.

    >>
    >> Im pretty sure the error is in line 7.
    >> [...]


    Please trim your quotes to the necessary minimum.

    > [...] Line 7 is the standard comment end for JavaScript.


    Nonsense. It is a CDC (Comment Declaration Close) delimiter hidden from the
    JS engine as a single-line comment; a practice that, from the standards
    perspective, has always been obsolete (HTML 3.2 introduced the `script'
    element, a UA is FUBAR if it renders its content).

    The point I think Georg was trying to make, though, is that your script code
    is syntactically valid, and without knowing about makerequest() there is no
    telling where it might otherwise go wrong.

    > On your suggestion, I took the comment out. Didn't change anything?


    It might have, especially with XHTML, which would then not be well-formed.

    > Here is the makerequest function. It's right out of the book,
    > "Beginning Ajax with PHP." It seems to work in all the book examples.
    >
    > function makerequest(serverPage, objID) {
    >
    > var obj = document.getElementById(objID);
    > xmlhttp.open("GET", serverPage);


    What is `xmlhttp'?

    > xmlhttp.onreadystatechange = function() {
    > if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {


    Is this running via HTTP(S) on a Web server? Otherwise status can be 0.

    > obj.innerHTML = xmlhttp.responseText;


    Possibility: The space-containing `div' elements are considered empty and
    thus can be non-existent at the mercy of the DOM implementation.

    That said, with (server-side) PHP you probably don't need all that but you
    can (and should) include the form controls in the first place.

    <http://www.jibbering.com/faq/faq_notes/clj_posts.html#ps1DontWork>
    <http://www.jibbering.com/faq/#debugging>


    PointedEars
    Thomas 'PointedEars' Lahn, Jan 13, 2009
    #5
  6. Bruce A. Julseth meinte:

    > On your suggestion, I took the comment out. Didn't change anything? Here is
    > the makerequest function. It's right out of the book, "Beginning Ajax with
    > PHP." It seems to work in all the book examples.


    I hope you realize that this code is only for toying around, nothing
    that can be used on a "serious" webpage.

    > function makerequest(serverPage, objID) {
    >
    > var obj = document.getElementById(objID);
    > xmlhttp.open("GET", serverPage);
    > xmlhttp.onreadystatechange = function() {
    > if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
    > obj.innerHTML = xmlhttp.responseText;
    > }
    > }
    > xmlhttp.send(null);
    > }


    And where is xmlhttp defined? With every call of makerequest() xmlhttp
    gets freshly initialized. Does this make clearer, where the erroneous
    behaviour comes from?

    Gregor
    Gregor Kofler, Jan 13, 2009
    #6
  7. Thomas 'PointedEars' Lahn wrote:
    > The point I think Georg was trying to make, though, [...]


    *Gregor*, sorry. Somehow I always manage to confuse you two.


    PointedEars
    Thomas 'PointedEars' Lahn, Jan 13, 2009
    #7
  8. Gregor Kofler wrote:
    > Bruce A. Julseth meinte:
    >> function makerequest(serverPage, objID) {
    >> [...]
    >> xmlhttp.open("GET", serverPage);
    >> [...]
    >> xmlhttp.send(null);
    >> }

    >
    > And where is xmlhttp defined? With every call of makerequest() xmlhttp
    > gets freshly initialized. Does this make clearer, where the erroneous
    > behaviour comes from?


    It does (d'oh!). JFTR: One MUST NOT call x.open() or x.send() while a
    request with the object referred to by `x' is in progress. At least the
    Gecko source code tells the whole story.


    PointedEars
    Thomas 'PointedEars' Lahn, Jan 13, 2009
    #8
  9. "Jeremy J Starcher" <> wrote in message
    news:w69bl.11284$...
    > On Tue, 13 Jan 2009 17:31:33 -0500, Bruce A. Julseth wrote:
    >
    >> "Gregor Kofler" <> wrote in message
    >> news:Fn8bl.138$...
    >>> Bruce A. Julseth meinte:
    >>>> I have the following code snippet:
    >>>
    >>> It /definitely/ is a snippet.
    >>>

    >
    > [ Code Snipped ]
    >
    >>>
    >>> Im pretty sure the error is in line 7.
    >>>
    >>> HTH, Gregor

    >>
    >> Thanks for the response. Line 7 is the standard comment end for
    >> JavaScript. On your suggestion, I took the comment out. Didn't change
    >> anything? Here is the makerequest function. It's right out of the book,
    >> "Beginning Ajax with PHP." It seems to work in all the book examples.
    >>
    >> function makerequest(serverPage, objID) {
    >>
    >> var obj = document.getElementById(objID); xmlhttp.open("GET",
    >> serverPage);
    >> xmlhttp.onreadystatechange = function() {
    >> if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
    >> obj.innerHTML = xmlhttp.responseText;
    >> }
    >> }
    >> xmlhttp.send(null);
    >> }

    >
    > Gregor's comment was a more-or-less standard response when one doesn't
    > show enough code to be useful. In this case, your original snipping did
    > not contain the section that was in error.
    >
    > (And using <!-- //--> with Javascript went obsolete about 10 years ago or
    > so. Its only standard by people who don't know why they were used and
    > why not to. They part of my list on how to recognize bad Javascript.)
    >
    > I would recommend and entirely different approach anyways. Since you are
    > -already- using php to generate page content, generate the ENTIRE page
    > using PHP and serve it. Javascript should [almost] always be an
    > ENHANCEMENT to a page, not a requirement.
    >
    >> makerequest('SelectMonth.htm','Mo');

    >
    > Secondly, if you are only loading html fragments, as opposed to an entire
    > page, I would not use the extension '.htm' Personally, I'd use '.txt'.
    >
    > You still have not shown enough context to allow anyone to answer your
    > question. Posting a link would be a Good Idea(tm).


    I admit that I am a novice at JavaScript, but I still see the comment
    characters in books that have 2007 and 2008 copywrite dates. So, I have
    continued to use them.

    Doing the entire page in PHP would solve every problem but one. AJAX seems
    to me to the best way to solve this one problem, namely I want to CHANGE the
    DAY Select/Option list to agree with the number of days in a month. When a
    client chooses February, I only want 28/29 days displayed, January, 31 days,
    etc.

    I'm DON"T know how to do this. Suggestion?
    Bruce A. Julseth, Jan 14, 2009
    #9
  10. "Thomas 'PointedEars' Lahn" <> wrote in message
    news:...
    > Bruce A. Julseth wrote:
    >> "Gregor Kofler" wrote:
    >>> Bruce A. Julseth meinte:
    >>>> function LoadLists() {
    >>>> makerequest('SelectMonth.htm','Mo');
    >>>> makerequest('SelectDay.htm','Da');
    >>>> makerequest('SelectYear.htm','Yr');
    >>>> }
    >>>>
    >>>> //-->
    >>>> </script>
    >>>>
    >>>> <body onload="LoadLists()">
    >>>> <form name="form1" id="form1" method="post" action="">

    >
    > The form might not need a name or an ID.
    >
    >>>> <label for="select">Year</label>
    >>>> <div id='Yr'> </div>
    >>>> <label for="select">Month</label>
    >>>> <div id='Mo'> </div>
    >>>> <label for="select">Day</label>
    >>>> <div id='Da'> </div>
    >>>> </form>
    >>>> </body>
    >>>>
    >>>> Only the last call in LoadList() is in the web page when it is
    >>>> displayed.
    >>>> I can make one of the other calls the last call and it will be
    >>>> displayed.
    >>>> The Select???.htm's contain <select><option> html.
    >>>
    >>> Im pretty sure the error is in line 7.
    >>> [...]

    >
    > Please trim your quotes to the necessary minimum.
    >
    >> [...] Line 7 is the standard comment end for JavaScript.

    >
    > Nonsense. It is a CDC (Comment Declaration Close) delimiter hidden from
    > the
    > JS engine as a single-line comment; a practice that, from the standards
    > perspective, has always been obsolete (HTML 3.2 introduced the `script'
    > element, a UA is FUBAR if it renders its content).
    >
    > The point I think Georg was trying to make, though, is that your script
    > code
    > is syntactically valid, and without knowing about makerequest() there is
    > no
    > telling where it might otherwise go wrong.
    >
    >> On your suggestion, I took the comment out. Didn't change anything?

    >
    > It might have, especially with XHTML, which would then not be well-formed.
    >
    >> Here is the makerequest function. It's right out of the book,
    >> "Beginning Ajax with PHP." It seems to work in all the book examples.
    >>
    >> function makerequest(serverPage, objID) {
    >>
    >> var obj = document.getElementById(objID);
    >> xmlhttp.open("GET", serverPage);

    >
    > What is `xmlhttp'?
    >
    >> xmlhttp.onreadystatechange = function() {
    >> if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {

    >
    > Is this running via HTTP(S) on a Web server? Otherwise status can be 0.
    >
    >> obj.innerHTML = xmlhttp.responseText;

    >
    > Possibility: The space-containing `div' elements are considered empty and
    > thus can be non-existent at the mercy of the DOM implementation.
    >
    > That said, with (server-side) PHP you probably don't need all that but you
    > can (and should) include the form controls in the first place.
    >
    > <http://www.jibbering.com/faq/faq_notes/clj_posts.html#ps1DontWork>
    > <http://www.jibbering.com/faq/#debugging>
    >
    >
    > PointedEars


    Okay... My snippet was to "LITTLE." Here is all the Javascript and HTML for
    the page...

    <script type="text/javascript">
    //Create a boolean variable to check for a valid Internet Explorer
    instance.
    var xmlhttp = false;

    //Check if we are using IE.
    try {
    //If the Javascript version is greater than 5.
    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    // alert("You are using Microsoft IE");
    } catch (e) {
    //If not, then use the older active x object.
    try {
    //If we are using MS.
    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    // alert("You are using Microsoft IE");
    } catch (E) {
    //Else we must be using a non-IE browser.
    xmlhttp = false;
    }
    }

    //If we are using a non-IE browser, create a javascript instance of the
    object.
    if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    xmlhttp = new XMLHttpRequest();
    // alert("You are not using Microsoft IE");
    }


    /*
    var xmlhttp;

    //If, the activexobject is available, we must be using IE.
    if (window.ActiveXObject){
    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    } else {
    //Else, we can use the native Javascript handler.
    xmlhttp = new XMLHttpRequest();
    }
    */

    function makerequest(serverPage, objID) {

    var obj = document.getElementById(objID);
    xmlhttp.open("GET", serverPage);
    xmlhttp.onreadystatechange = function() {
    if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
    obj.innerHTML = xmlhttp.responseText;
    }
    }
    xmlhttp.send(null);
    }

    function LoadLists() {
    makerequest('SelectDay.htm','Da');
    makerequest('SelectYear.htm','Yr');
    makerequest('SelectMonth.htm','Mo');
    }

    </script>
    </head>
    <body onload="LoadLists()">
    <form name="form1" id="form1" method="post" action="">
    <label for="select1">Year<div id='Yr'></div></label>
    <label for="select2">Month<div id='Mo'></div></label>
    <label for="select3">Day<div id='Da'></div></label>
    </form>
    </body>
    Bruce A. Julseth, Jan 14, 2009
    #10
  11. "Gregor Kofler" <> wrote in message
    news:vh9bl.145$...
    > Bruce A. Julseth meinte:
    >
    >> On your suggestion, I took the comment out. Didn't change anything? Here
    >> is
    >> the makerequest function. It's right out of the book, "Beginning Ajax
    >> with
    >> PHP." It seems to work in all the book examples.

    >
    > I hope you realize that this code is only for toying around, nothing
    > that can be used on a "serious" webpage.


    Oh, boy.. What's wrong with code? I'd GREATLY appreciate you comments on how
    I need to improve it. I'm espcially interested in the function makerequest.
    I know my HTML Web is "play" code. I'm trying to find out how load and
    modify my Select/Option code dynamically. Thanks...

    >
    >> function makerequest(serverPage, objID) {
    >>
    >> var obj = document.getElementById(objID);
    >> xmlhttp.open("GET", serverPage);
    >> xmlhttp.onreadystatechange = function() {
    >> if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
    >> obj.innerHTML = xmlhttp.responseText;
    >> }
    >> }
    >> xmlhttp.send(null);
    >> }

    >
    > And where is xmlhttp defined? With every call of makerequest() xmlhttp
    > gets freshly initialized. Does this make clearer, where the erroneous
    > behaviour comes from?


    I loaded all the JavaScript in another response. Appreciate you looking at
    it and see if you can identify my problem. I've removed the <!--/-->
    comment!! Thanks...

    >
    > Gregor
    Bruce A. Julseth, Jan 14, 2009
    #11
  12. Bruce A. Julseth wrote:

    > I admit that I am a novice at JavaScript, but I still see the comment
    > characters in books that have 2007 and 2008 copywrite dates. So, I have
    > continued to use them.


    In fact, I have yet to see a book about the use of ECMAScript
    implementations that can be recommended to novices.

    > Doing the entire page in PHP would solve every problem but one.


    You are mistaken.

    > AJAX seems to me to the best way to solve this one problem, namely I want
    > to CHANGE the DAY Select/Option list to agree with the number of days in
    > a month. When a client chooses February, I only want 28/29 days displayed,
    > January, 31 days, etc.


    You can (and SHOULD) generate the controls with server-side PHP, and update
    them with client-side scripting only when necessary. You really don't need
    XHR for this; ECMAScript implementations provide a Date object that you can
    use without further request.

    > I'm DON"T know how to do this. Suggestion?


    STFW and this newsgroup for the `options' NodeList. And trim your quotes.

    <http://jibbering.com/faq/>


    PointedEars
    Thomas 'PointedEars' Lahn, Jan 14, 2009
    #12
  13. Bruce A. Julseth wrote:

    > "Thomas 'PointedEars' Lahn" <> wrote in message
    > news:...


    Please don't post attribution novels.

    <http://insideoe.com/>

    >> Bruce A. Julseth wrote:
    >>> "Gregor Kofler" wrote:
    >>>> Bruce A. Julseth meinte:
    >>>>> function LoadLists() {
    >>>>>  makerequest('SelectMonth.htm','Mo');
    >>>>>  makerequest('SelectDay.htm','Da');
    >>>>>  makerequest('SelectYear.htm','Yr');
    >>>>> }
    >>>>>
    >>>>> //-->
    >>>>>  </script>
    >>>>> [...]
    >>>>
    >>>> Im pretty sure the error is in line 7.
    >>>> [...]

    >>
    >> Please trim your quotes to the necessary minimum.


    (Which part of that did you not understand?)

    >> [...]
    >> The point I think Georg was trying to make, though, is that your script
    >> code is syntactically valid, and without knowing about makerequest()
    >> there is no telling where it might otherwise go wrong.
    >>
    >> [...]
    >>> function makerequest(serverPage, objID) {
    >>>
    >>> var obj = document.getElementById(objID);
    >>> xmlhttp.open("GET", serverPage);

    >>
    >> What is `xmlhttp'?
    >> [...]

    >
    > Okay... My snippet was to "LITTLE."


    (Please don't SHOUT here.)

    > Here is all the Javascript and HTML for the page...


    Thanks, although it turned out already that it was not longer necessary for
    analyzing the problem. It is useful as a bad example, though.

    > <script type="text/javascript">
    > //Create a boolean variable to check for a valid Internet Explorer
    > instance.


    The comment does not make any sense at all. Was this your idea or is it
    from the book(s)?

    > var xmlhttp = false;


    var xmlhttp = null;

    makes more sense, as *an object reference* will be assigned later.

    > //Check if we are using IE.


    Nonsense.

    > try {
    > //If the Javascript version is greater than 5.
    > xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");


    The "Javascript version" (whatever the author thought that would be) has
    nothing to do with the MSXML version. The former is the programming
    language, the latter is an API that the UA's runtime environment provides
    which can be used with that language (and other languages).

    Get yourself informed, or reuse the book(s) (for a nice camp fire, paper
    flyers ... you get the idea?)

    <http://PointedEars.de/es-matrix/>

    > // alert("You are using Microsoft IE");


    A distinct possibility with MSXML support being present, certainly not a
    necessity.

    > } catch (e) {
    > //If not, then use the older active x object.

    ^^^^^
    > try {
    > //If we are using MS.
    > xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");


    In 99.9% of the cases, this identifier string and test, which will AFAIK
    pick the *newest* installed version of MSXML, suffices for XHR.

    > // alert("You are using Microsoft IE");


    Nonsense.

    > } catch (E) {
    > //Else we must be using a non-IE browser.
    > xmlhttp = false;


    Again, ActiveX support has nothing to do with IE or not IE.

    > }
    > }
    >
    > //If we are using a non-IE browser, create a javascript instance of the
    > object.


    The comment is nonsense as IE 7 supports XMLHttpRequest(), too. It only
    will not execute the block statement below because it also supports
    ActiveXObject().

    > if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {


    Insufficient feature test. That XMLHttpRequest is not `undefined' is not an
    indication that it can be called.

    > xmlhttp = new XMLHttpRequest();


    Missing exception handling although that would not add more incompatibility
    to the code. (try...catch was not introduced before ECMAScript 3; it
    causes the code to not compile with older implementations and in older or
    lightweight user agents, and thus must be handled specially).

    > // alert("You are not using Microsoft IE");


    Non sequitur.

    > }
    >
    >
    > /*
    > var xmlhttp;
    >
    > //If, the activexobject is available, we must be using IE.
    > if (window.ActiveXObject){
    > xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    > } else {
    > //Else, we can use the native Javascript handler.
    > xmlhttp = new XMLHttpRequest();
    > }
    > */


    The same nonsense repeated.

    > function makerequest(serverPage, objID) {
    > [...]


    That's online already.


    PointedEars
    Thomas 'PointedEars' Lahn, Jan 14, 2009
    #13
  14. Bruce A. Julseth meinte:
    > "Gregor Kofler" <> wrote in message
    > news:vh9bl.145$...
    >> Bruce A. Julseth meinte:
    >>
    >>> On your suggestion, I took the comment out. Didn't change anything? Here
    >>> is
    >>> the makerequest function. It's right out of the book, "Beginning Ajax
    >>> with
    >>> PHP." It seems to work in all the book examples.

    >> I hope you realize that this code is only for toying around, nothing
    >> that can be used on a "serious" webpage.

    >
    > Oh, boy.. What's wrong with code? I'd GREATLY appreciate you comments on how
    > I need to improve it. I'm espcially interested in the function makerequest.


    Hey, it's *you* who got the smart book. The code is nothing more than a
    quick simple example.

    It features
    - no feature tests
    - no IE support
    - no timeout handling
    - no cancellation of requests
    - etc.

    Perhaps others are willing to provide a detailed and robust solution for
    you. Though I doubt that. It has been a topic here frequently and there
    are (a few good and a lot bad) libraries out there.

    Gregor
    Gregor Kofler, Jan 14, 2009
    #14
  15. Gregor Kofler meinte:

    > - no feature tests
    > - no IE support


    Oops. I read your full example too late. Thomas has already made his
    annotations.

    Gregor
    Gregor Kofler, Jan 14, 2009
    #15
  16. In comp.lang.javascript message <w69bl.11284$
    om>, Tue, 13 Jan 2009 23:05:00, Jeremy J Starcher <>
    posted:
    >
    >(And using <!-- //--> with Javascript went obsolete about 10 years ago or
    >so. Its only standard by people who don't know why they were used and
    >why not to. They part of my list on how to recognize bad Javascript.)


    That is an unsafe assumption, because it presumes that the JavaScript is
    only going to be read by people, editors, and browsers not much more
    than (maybe) a decade old.

    It ignores the possibility of the comment being there because the file
    containing the JavaScript will be processed, before loading to the Web,
    by an elderly but still useful piece of software which was designed to
    read HTML (understanding <!-- and -->) but not to read JavaScript.

    --
    (c) John Stockton, nr London UK. ??@merlyn.demon.co.uk Turnpike v6.05 MIME.
    Web <URL:http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.
    In MS OE, choose Tools, Options, Send; select Plain Text for News and E-mail.
    Don't quote more than is needed, and respond after each quoted part.
    Dr J R Stockton, Jan 14, 2009
    #16
  17. "Gregor Kofler" <> wrote in message
    news:6pibl.15$...
    > Gregor Kofler meinte:
    >
    >> - no feature tests
    >> - no IE support

    >
    > Oops. I read your full example too late. Thomas has already made his
    > annotations.
    >
    > Gregor


    Thanks for the response. I still don't know why my "example" doesn't work.
    Maybe someone knows of an example somewhere. What I want to do is create 3
    drop down list boxes:, Year, Month, Day. On load, I want the Year to be
    loaded with the current year and next year. No problem. I know how to do
    that. I want to the Month box to loaded with the 12 months. No problem. I
    know how to do that. I want the Day box to load, after the Month is selected
    with the days in the month selected. I don't know how to do that. I was
    expecting to use AJAX to load the Day box with an "onblur" response to the
    month selection.

    Does anyone know of an example that does what I am trying to do?

    Thanks again for the response.
    Bruce A. Julseth, Jan 14, 2009
    #17
  18. Bruce A. Julseth meinte:
    > "Gregor Kofler" <> wrote in message
    > news:6pibl.15$...
    >> Gregor Kofler meinte:
    >>
    >>> - no feature tests
    >>> - no IE support

    >> Oops. I read your full example too late. Thomas has already made his
    >> annotations.
    >>
    >> Gregor

    >
    > Thanks for the response. I still don't know why my "example" doesn't work.
    > Maybe someone knows of an example somewhere. What I want to do is create 3
    > drop down list boxes:, Year, Month, Day.


    Thomas explained it already. You're gonna need 3 *different* XHR objects
    and not re-initialize the same one all the time.

    Gregor
    Gregor Kofler, Jan 14, 2009
    #18
  19. Re: AJAX problem)

    Dr J R Stockton wrote:

    > Jeremy J Starcher posted:
    >> (And using <!-- //--> with Javascript went obsolete about 10 years ago or
    >> so. Its only standard by people who don't know why they were used and
    >> why not to. They part of my list on how to recognize bad Javascript.)

    >
    > That is an unsafe assumption, because it presumes that the JavaScript is
    > only going to be read by people, editors, and browsers not much more
    > than (maybe) a decade old.


    Nonsense. HTML 2.0 (as of 1995-11) has been officially declared OBSOLETE
    about eight years, six months ago:

    <http://tools.ietf.org/html/rfc2854>

    > It ignores the possibility of the comment being there because the file
    > containing the JavaScript will be processed, before loading to the Web,
    > by an elderly but still useful piece of software which was designed to
    > read HTML (understanding <!-- and -->) but not to read JavaScript.


    That's but a lame excuse for still using and supporting software FUBAR. If
    that piece of software was really that useful to everyone, one would think
    their authors would have taken the time to update it by now. For it is not
    that they could not use a working open-source parser instead.


    PointedEars
    Thomas 'PointedEars' Lahn, Jan 14, 2009
    #19
  20. In comp.lang.javascript message <>,
    Wed, 14 Jan 2009 04:53:34, Thomas 'PointedEars' Lahn
    <> posted:
    >Bruce A. Julseth wrote:
    >
    >> "Thomas 'PointedEars' Lahn" <> wrote in message
    >> news:...

    >
    >Please don't post attribution novels.


    Ignore that; Lahn is a control freak with peculiar ideas. The bandwidth
    consumed by an informative attribution is negligible; it is much less
    than that consumed by the articles requires to inform those who suffer
    from Lahn that the fault lies in him and not in what they have posted.

    --
    (c) John Stockton, nr London UK. replyYYWW merlyn demon co uk Turnpike 6.05.
    Web <URL:http://www.uwasa.fi/~ts/http/tsfaq.html> -> Timo Salmi: Usenet Q&A.
    Web <URL:http://www.merlyn.demon.co.uk/news-use.htm> : about usage of News.
    No Encoding. Quotes precede replies. Snip well. Write clearly. Mail no News.
    Dr J R Stockton, Jan 14, 2009
    #20
    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. Replies:
    20
    Views:
    1,882
    d1srupt3r
    Mar 31, 2008
  2. darrel

    beginner AJAX questions (AJAX.net)

    darrel, Apr 27, 2006, in forum: ASP .Net
    Replies:
    5
    Views:
    2,424
    Flinky Wisty Pomm
    Apr 28, 2006
  3. jobs
    Replies:
    0
    Views:
    353
  4. =?Utf-8?B?QnJpYW4gRWR3YXJkcw==?=

    Deploying ASP.NET AJAX-Enabled Web site to host without AJAX insta

    =?Utf-8?B?QnJpYW4gRWR3YXJkcw==?=, Feb 20, 2007, in forum: ASP .Net
    Replies:
    2
    Views:
    583
    Patrick
    Feb 21, 2007
  5. minnie
    Replies:
    1
    Views:
    672
    Andrew Thompson
    Dec 13, 2006
Loading...

Share This Page