Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Apr 2004
    Posts
    684
    Thanks
    24
    Thanked 1 Time in 1 Post

    Not enough arguments?

    Hey guys..... I've been going over this code for the last few hours & it seems once I get past one problem there is another.... this is frustrating... at the moment I'm getting a javascript error of "not enough arguments"..

    Here is the error:



    Here is the javascript code:

    Code:
    function getModels()
    {
    
     var xmlHttp
    
     xmlHttp=GetXmlHttpObject();
    	
    	if (xmlHttp==null)
    	  {
    	  alert ("Your browser does not support AJAX!");
    	  return;
    	  }
    	  
     var url="xml.xml";
     xmlHttp.open("GET",url,true);
     xmlHttp.setRequestHeader("Content-Type: text/xml; charset=utf-8");
     xmlHttp.send(null);
     
     	 xmlHttp.onreadystatechange=function() {
     
    	 	if (xmlHttp.readyState==4) {
     
     		poo = xmlHttp.responseXML.documentElement;
     		alert(poo.getElementsByTagName("book")[0].nodeValue);
     		return;
     
    	 	 var books = xmlHttp.responseXML.getElementsByTagName('book');
    	
    			for (var i=0;i<books.length;i++)
    			{
    				var x = document.createElement('div');
    				x.className = 'book';
    				var y = document.createElement('h3');
    				y.appendChild(document.createTextNode(getNodeValue(books[i],'title')));
    				x.appendChild(y);
    				var z = document.createElement('p');
    				z.className = 'moreInfo';
    				z.appendChild(document.createTextNode('By ' + getNodeValue(books[i],'author') + ', ' + getNodeValue(books[i],'publisher')));
    				x.appendChild(z);
    				var a = document.createElement('img');
    				a.src = books[i].getElementsByTagName('cover')[0].getAttribute('src');
    				x.appendChild(a);
    				var b = document.createElement('p');
    				b.appendChild(document.createTextNode(getNodeValue(books[i],'blurb')));
    				x.appendChild(b);
    				document.getElementById('blah').appendChild(x);
    			}
    		
    		}
    		
    	}
    	
    }
    
    function getNodeValue(obj,tag)
    {
    	return obj.getElementsByTagName(tag)[0].firstChild.nodeValue;
    }
    
    function GetXmlHttpObject()
    {
    var xmlHttp=null;
    try
      {
      // Firefox, Opera 8.0+, Safari
      xmlHttp=new XMLHttpRequest();
      }
    catch (e)
      {
      // Internet Explorer
      try
        {
        xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
        }
      catch (e)
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      }
    return xmlHttp;
    }
    Here is my XML file..

    Code:
    <?xml version="1.0" encoding="UTF-8" ?> 
    <rss version="2.0">
    <channel>
    <books>
    	<book>
    		<title>JavaScript, the Definitive Guide</title>
    		<publisher>O'Reilly</publisher>
    		<author>David Flanagan</author>
    		<cover src="/images/cover_defguide.jpg" />
    		<blurb>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</blurb>
    	</book>
    	<book>
    		<title>DOM Scripting</title>
    		<publisher>Friends of Ed</publisher>
    		<author>Jeremy Keith</author>
    		<cover src="/images/cover_domscripting.jpg" />
    		<blurb>Praesent et diam a ligula facilisis venenatis.</blurb>
    	</book>
    	<book>
    		<title>DHTML Utopia: Modern Web Design using JavaScript &amp; DOM</title>
    		<publisher>Sitepoint</publisher>
    		<author>Stuart Langridge</author>
    		<cover src="/images/cover_utopia.jpg" />
    		<blurb>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</blurb>
    	</book>
    </books>
    </channel>
    </rss>
    Thanks!

  • #2
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    try moving send after you set the onreadystatechange

    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

  • #3
    Regular Coder
    Join Date
    Apr 2004
    Posts
    684
    Thanks
    24
    Thanked 1 Time in 1 Post
    nope.. same problem.

  • #4
    New to the CF scene
    Join Date
    Jun 2008
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    problem is in the send() function

    your problem is in the send() function

    pass something there.
    besides null.

    I had the same problem
    and it worked when i passed something to the send function.

  • #5
    New to the CF scene
    Join Date
    Sep 2008
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by bipins View Post
    your problem is in the send() function

    pass something there.
    besides null.

    I had the same problem
    and it worked when i passed something to the send function.
    Thank you very much, this fixed my problem


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •