Go Back   CodingForums.com > :: Client side development > JavaScript programming > Ajax and Design

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-20-2007, 03:33 AM   PM User | #1
cyphix
Regular Coder

 
Join Date: Apr 2004
Posts: 682
Thanks: 24
Thanked 1 Time in 1 Post
cyphix is an unknown quantity at this point
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!
cyphix is offline   Reply With Quote
Old 07-20-2007, 03:40 AM   PM User | #2
A1ien51
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
A1ien51 will become famous soon enough
try moving send after you set the onreadystatechange

Eric
__________________
Tech Author [Ajax In Action, JavaScript: Visual Blueprint]
A1ien51 is offline   Reply With Quote
Old 07-20-2007, 04:01 AM   PM User | #3
cyphix
Regular Coder

 
Join Date: Apr 2004
Posts: 682
Thanks: 24
Thanked 1 Time in 1 Post
cyphix is an unknown quantity at this point
nope.. same problem.
cyphix is offline   Reply With Quote
Old 06-23-2008, 08:19 AM   PM User | #4
bipins
New to the CF scene

 
Join Date: Jun 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
bipins is an unknown quantity at this point
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.
bipins is offline   Reply With Quote
Old 09-09-2008, 05:26 AM   PM User | #5
batitombo
New to the CF scene

 
Join Date: Sep 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
batitombo is an unknown quantity at this point
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
batitombo is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:35 PM.


Advertisement
Log in to turn off these ads.