trying to loop an xml page from ajax

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

    trying to loop an xml page from ajax

    Got this code, which works fine in FF3 - it dynamically redraws a menu
    from user input.
    ####
    function so_clearInnerHT ML(obj) {
    // so long as obj has children, remove them
    while(obj.first Child) obj.removeChild (obj.firstChild );
    } - this just for info - ignore that there is no function around the next
    bit!

    if (httpRequest.st atus == 200) {
    var xmldoc = httpRequest.res ponseXML;
    //var objNodeList;
    //objNodeList = xmldoc.getEleme ntsByTagName
    ('systemname');
    so_clearInnerHT ML(document.get ElementById
    ("systemslist") );

    // loop through the returned xml list for entries and
    append them back to the div
    var x = 0;
    while (xmldoc.getElem entsByTagName(' systemname')[x]) {
    //alert('counted['+i+']');
    var sysname = xmldoc.getEleme ntsByTagName
    ('systemname')[x].childNodes[0].nodeValue;
    var sysid = xmldoc.getEleme ntsByTagName('s ystemid')
    [x].childNodes[0].nodeValue;
    //alert('systemna me['+sysname+']');
    //alert('systemid['+sysid+']');
    // create a DIV element, using the variable eLink as
    a reference to it
    eLink = document.create Element("a");
    //use the setAttribute method to assign it an id
    eLink.setAttrib ute("href","fin dsystem.asp?
    systemid="+sysi d);
    // add the text from 'systemname' to the anchor
    element
    eLink.appendChi ld(document.cre ateTextNode
    (xmldoc.getElem entsByTagName(' systemname')[x].childNodes[0].nodeValue));
    // append your newly created element to an already
    existing element.
    document.getEle mentById("syste mslist").append Child
    (eLink);
    eBreak = document.create Element("br");
    document.getEle mentById("syste mslist").append Child
    (eBreak);
    x++;
    }

    } else {
    alert('There was a problem with the request.');
    }
    ####

    doesn't repopulate the menu via IE6 or 7
    I tried to switch the while to a for -
    ##
    for (var i=0; i<objNodeList.l ength; i++) {
    ##
    (ignore the x switch in i)

    but that returns a zero length list of nodes for IE, and still works for
    FF

    is there another way for IE to see the existance of the node list, or do
    I need to approach the looping some other way?
  • Martin Honnen

    #2
    Re: trying to loop an xml page from ajax

    s_m_b wrote:
    is there another way for IE to see the existance of the node list, or do
    I need to approach the looping some other way?
    Is responseXML in IE populated? Make sure the server sends the XML with
    HTTP response header Content-Type: application/xml (or text/xml) to
    ensure that IE/MSXML populate the responseXML property.
    With IE you can also check responseXML.par seError.errorCo de to test
    whether IE had any problems parsing the XML the server sent.


    --

    Martin Honnen

    Comment

    • s_m_b

      #3
      Re: trying to loop an xml page from ajax

      Martin Honnen <mahotrash@yaho o.dewrote in
      news:4862334d$0 $7547$9b4e6d93@ newsspool1.arco r-online.net:
      Is responseXML in IE populated? Make sure the server sends the XML
      with HTTP response header Content-Type: application/xml (or text/xml)
      to ensure that IE/MSXML populate the responseXML property.
      With IE you can also check responseXML.par seError.errorCo de to test
      whether IE had any problems parsing the XML the server sent.
      >
      Yes - using
      if (httpRequest.ov errideMimeType) {
      httpRequest.ove rrideMimeType(' text/xml');
      }

      for all browser flavours.

      However, what I hadn't thought of - an should have - was that the file-
      specific header in IIS was not sending content-type:text/xml

      working now fine, although getting IE to respond to the search box being
      cleared is another matter...

      Comment

      • Martin Honnen

        #4
        Re: trying to loop an xml page from ajax

        s_m_b wrote:
        Yes - using
        if (httpRequest.ov errideMimeType) {
        httpRequest.ove rrideMimeType(' text/xml');
        }
        >
        for all browser flavours.
        With IE overrideMimeTyp e is not supported so the above does not help for IE.

        --

        Martin Honnen

        Comment

        • s_m_b

          #5
          Re: trying to loop an xml page from ajax

          Martin Honnen <mahotrash@yaho o.dewrote in
          news:48626143$0 $27439$9b4e6d93 @newsspool4.arc or-online.net:
          >
          With IE overrideMimeTyp e is not supported so the above does not help
          for IE.
          >
          Oh, so this is a bit irrelevant... OK

          Within the same context, sort of, does IE not detect 'backspace' keys with
          onkeypress? With FF, I can delete the input field and Ajax responds, but IE
          just ignores this, until I type another search string in.

          Comment

          • Martin Honnen

            #6
            Re: trying to loop an xml page from ajax

            s_m_b wrote:
            Within the same context, sort of, does IE not detect 'backspace' keys with
            onkeypress? With FF, I can delete the input field and Ajax responds, but IE
            just ignores this, until I type another search string in.
            I think IE fires keyup and keydown for the backspace key:


            --

            Martin Honnen

            Comment

            • s_m_b

              #7
              Re: trying to loop an xml page from ajax

              Martin Honnen <mahotrash@yaho o.dewrote in
              news:486265df$0 $27447$9b4e6d93 @newsspool4.arc or-online.net:
              s_m_b wrote:
              >
              >Within the same context, sort of, does IE not detect 'backspace' keys
              >with onkeypress? With FF, I can delete the input field and Ajax
              >responds, but IE just ignores this, until I type another search
              >string in.
              >
              I think IE fires keyup and keydown for the backspace key:

              >
              Yes - seems happier with both. Thanks for your help.

              Comment

              Working...