xml.childNodes.length issue

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • praveensewak
    New Member
    • Jun 2007
    • 2

    #1

    xml.childNodes.length issue

    I have written an AJAX script:

    for (j=0;j<xml.chil dNodes.length;j ++){
    /*** CODE HERE ****/
    }

    In IE, i get the corrent code rendered, BUT in Firefox, i only get the first entry!!!

    When i alert(xml.child Nodes.length) in Firefox, i ALWAYS get 1!!!! it works fine in IE, Opera, etc....

    Please someone (anyone!) help!!!
  • Dököll
    Recognized Expert Top Contributor
    • Nov 2006
    • 2379

    #2
    Originally posted by praveensewak
    I have written an AJAX script:
    Code:
    [I]for (j=0;j<xml.childNodes.length;j++){
    		/*** CODE HERE ****/
    }[/I]
    In IE, i get the corrent code rendered, BUT in Firefox, i only get the first entry!!!

    When i alert(xml.child Nodes.length) in Firefox, i ALWAYS get 1!!!! it works fine in IE, Opera, etc....

    Please someone (anyone!) help!!!
    Greetings and salutations, praveensewak!

    Please have a look here, see if helpful:
    http://www.google.com/search?hl=en&rl s=com.microsoft %3Aen-us%3AIE-SearchBox&rlz=1 I7SUNA&q=AJAX+s cript+does+not+ work+in+Firefox %2C+Why%3F


    Please write if this did not do it for you.

    Dököll

    Comment

    • praveensewak
      New Member
      • Jun 2007
      • 2

      #3
      Hi...

      Thanks.... But i have spent like 4 hours looking for this.... just cant figure it out....

      here is the entire script.... as you can see, i want to dynamically load the banners.... i have also checked the makeHttpRequest () function in both Firefox and IE....

      :
      Code:
      [I]function makeHttpRequest(url, callback_function, return_xml)
      {
         var http_request = false;
      
         if (window.XMLHttpRequest) { // Mozilla, Safari,...
             http_request = new XMLHttpRequest();
             if (http_request.overrideMimeType) {
                 http_request.overrideMimeType('text/xml');
             }
      
         } else if (window.ActiveXObject) { // IE
             try {
                 http_request = new ActiveXObject("Msxml2.XMLHTTP");
             } catch (e) {
                 try {
                     http_request = new ActiveXObject("Microsoft.XMLHTTP");
                 } catch (e) {}
             }
         }
      
         if (!http_request) {
             alert('Unfortunatelly you browser doesn\'t support this feature.');
             return false;
         }
         http_request.onreadystatechange = function() {
             if (http_request.readyState == 4) {
                 if (http_request.status == 200) {
                     if (return_xml) {
                         eval(callback_function + '(http_request.responseXML)');
                     } else {
                         eval(callback_function + '(http_request.responseText)');
                     }
                 } else {
                     alert('There was a problem with the request.(Code: ' + http_request.status + ')');
                 }
             }
         }
         http_request.open('GET', url, true);
         http_request.send(null);
      }
      
      function loadBanner(xml)
      {
      	html_content = '<table width="640" border="0" cellspacing="0" cellpadding="0">';
      	
      	for (j=0;j<xml.childNodes.length;j++){
      		var id = xml.getElementsByTagName('id').item(j).firstChild.nodeValue;
      		var href = xml.getElementsByTagName('href').item(j).firstChild.nodeValue;
      		var src = xml.getElementsByTagName('src').item(j).firstChild.nodeValue;
      		var alt = xml.getElementsByTagName('alt').item(j).firstChild.nodeValue;
      		var pos = xml.getElementsByTagName('pos').item(j).firstChild.nodeValue;
      		
      		html_content += '<tr>';
      		html_content += '<td width="95" align="center" valign="middle"><input name="id" type="text" class="inputbox" id="id" style="width:30px" value="' + id +  '" /></td>';
      		html_content += '<td width="230" align="center" valign="middle"><input name="thumb" type="image" id="thumb" src="../images/' + src + '" alt="' + alt + '" width="90" height="66"></td>';
      		html_content += '<td width="210" align="center" valign="middle"><input name="url" type="text" class="inputbox" id="url" style="width:150px" value="' + href + '" /></td>';
      		html_content += '<td width="95" align="center" valign="middle"><img src="images/b_view.gif" alt="View Ad" width="16" height="16">&nbsp;&nbsp;<img src="images/b_modify.gif" alt="Edit Ad" width="16" height="16">&nbsp;&nbsp;<img src="images/b_delete.gif" alt="Delete Ad" width="16" height="16"> </td>';
      		html_content += '</tr>';
      	}
      	html_content += '</table>';
      	
      	document.getElementById('bannerlist').innerHTML = html_content;
      	document.getElementById("bannertable").style.display = "solid";
      
      }[/I]

      Comment

      • Dököll
        Recognized Expert Top Contributor
        • Nov 2006
        • 2379

        #4
        Have you tried uninstalling and resintalling FireFox?

        Jugging by the information I have read through the link I gave you, you should be okay.

        Perhaps something changed in FireFox that's not allowing your code to run properly.

        Comment

        Working...