Ajax Talk - Asynchronous javascript and xml discussion board
 FAQ   Search    Usergroups      Register   Profile   Check your messages   Log in 
Signup now to enjoy a range of free membership advantages !!
Ajax Talk - Moderators Wanted
Facing problem with the Error: NS_ERROR_ILLEGAL_VALUE

 
Post new topic   Reply to topic    Ajaxtalk.com Forum Index -> AJAX Help
View previous topic :: View next topic  
Author Message
simarjot
New one
New one


Joined: 17 Jun 2008
Posts: 2

PostPosted: Tue Jun 17, 2008 11:54 am    Post subject: Facing problem with the Error: NS_ERROR_ILLEGAL_VALUE Reply with quote

Hi people! I am a newbie into Ajax and I have surfed a lot to find the solution for my problem but in the end I am sorry to disturb you guys.

Well my problem is that when I make request in ajax to fetch the XML file, proper responseXML is not getting generated and I get the following error:

Code:

[Exception... "Component returned failiure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) http://nsIXMLHttpRequest.open" nsresult:"0x80070057 (NS_ERROR_ILLEGAL_VALUE)" location: "JS frame :: http://127.0.0.1/Ajax%20Version/scripts/loadcontents.js :: initXHR :: line 32" data: no]


I can't understand what that means. I am using WAMP2 Web Server and my Ajax script is mostly a client side plain JavaScript. I am pasting the JavaScript file below. Please help me out....

Code:

// JavaScript Document
window.onload = initXHR();
var xhr = false;
var url = "companies.xml";

function initXHR() {
   try {
      if (window.XMLHttpRequest) {
         xhr = new XMLHttpRequest();
      }
   }
   catch (error1) {
      if (window.ActiveXObject) {
         try {
            xhr = new ActiveXObject("Msxml2.XMLHTTP");
         }
         catch (error2) {
            if (window.ActiveXObject) {
               try {
                  xhr = new ActiveXObject("Microsoft.XMLHTTP");
               }
               catch (error3) {
                  alert("Sorry, but I couldn't create an XMLHttpRequest\n" + error3);
               }
            }
         }
      }
   }
   try {
      if (xhr) {
      xhr.onreadystatechange = setDataArray();
      xhr.open("GET", url, true);
      xhr.send(null);
      }
   }
   catch (error4) {
      alert("The page did not load correctly. Please reload.\n" + error4);
   }
   
   var allCatDivs = document.getElementsByTagName("div");
   for (var i=0; i<allCatDivs.length; i++) {
      allCatDivs[i].onclick = loadShelf();
   }   
}

function setDataArray() {
   try {
      if (xhr.readyState == 4) {
         if (xhr.status == 200) {
            if (xhr.responseXML) {
               var compCats = xhr.responseXML.getElementsByTagName("companyList")[0].childNodes;
            }
         }
      }
   }
   catch (error5) {
      alert("There was a problem with the request\n" + xhr.status);
   }
}

function loadShelf(OCE) {
   var theCatDiv = (OCE) ? OCE.target : window.event.srcElement;
   var catDivId = theCatDiv.getAttribute("id");
   var lens = document.getElementById("lensDiv").innerHTML = catDivId.data;
   var nextSibling = theCatdiv.nextElementSibling;
   var catLens = nextSibling.nextElementSibling.firstElementChild;
   /*for (var j=0; j<compCats.length; j++) {
      if (catDivId == compCats[j]) {
          var createCompDiv = document.createElement("div"); //Creation of company div 
            createCompDiv.setAttribute("class", "compDiv"); 
            createCompDiv.setAttribute("className", "compDiv"); 
            var lensDivImg = currentComp.getElementsByTagName("lensImage")[0].firstChild.data; 
            createCompDiv.setAttribute("lensImage", lensDivImg); 
            createCompDiv.setAttribute("onmouseover", "loadLens(this,catLens)"); 
            createCompDiv.setAttribute("onmouseout", "emptyLens()");     
            var createAnchor = document.createElement("a");  //Creation of company anchor tag
            var linkInfo = currentComp.getElementsByTagName("hLink")[0].firstChild.data; 
            createAnchor.setAttribute("href", linkInfo); 
            createAnchor.setAttribute("class", "a"); 
            createAnchor.setAttribute("target", "_blank"); 
            createCompDiv.appendChild(createAnchor);   
            var createImage = document.createElement("img");//Creation of company img tag 
            var imgSource = currentComp.getElementsByTagName("smallImage")[0].firstChild.data;// This info is used to set the src attrib 
            createImage.setAttribute("src", imgSource); 
            createImage.setAttribute("class", "compImg"); 
            createImage.setAttribute("className", "compImg"); 
             createAnchor.appendChild(createImage);          
            document.getElementById(nextSibling).appendChild(createCompDiv); //Company information being added to the body of the html page
      }
   }*/
}
/*
var lensDiv;
function loadLens(whichDiv, categoryLens)
{
 var lensDivImgSrc = whichDiv.getAttribute("lensImage");
 //lensDiv = document.getElementById("lensDiv");
 lensDiv = categoryLens;
 var createLensImg = document.createElement("img");
 createLensImg.setAttribute("src", lensDivImgSrc);
 lensDiv.appendChild(createLensImg);
}

function emptyLens()
{
 lensDiv.innerHTML = "";
}*/
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
simarjot
New one
New one


Joined: 17 Jun 2008
Posts: 2

PostPosted: Tue Jun 17, 2008 1:00 pm    Post subject: Reply with quote

I have further tested on my script by using the "readyState" and "status" properties to find out the problem in my script and I have found that my xhr object is being created but not getting initialized as the readyState value is 0.

What could be the reason for it not being initialized? Please help me out...
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
Display posts from previous:   
Post new topic   Reply to topic    Ajaxtalk.com Forum Index -> AJAX Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
 Advertisements
 XML & Copyright Notice 
    


Powered by phpBB © 2001, 2005 phpBB Group

What is according to Wikipedia: Ajax Web2.0 XML E4X


Link to our site:

  


del.icio.us digg spurl wists simpy newsvine blinklist furl blogmarks yahoo! myweb smarking ma.gnolia segnalo reddit fark technorati cosmos


Normal Bookmark


Partner Button Links:
Codecrunch.com: Webmaster Tutorials    One Ajax


Partner Text Links:
quomon | web20log | ajaxmatters | tableless | 456bereastreet | music charts | gift ideas | competitions | free xbox 360 | link trade ?


Credits:
it consultancy & project management lead generation zoekmachine optimalisatie steal these buttons seo expert