Jump to content
Sign in to follow this  
mobone

Puzzled About ()

Recommended Posts

<script language='javascript' type='text/javascript'>	function getHTTPObject(){	http = window.XMLHttpRequest ? new XMLHttpRequest : (window.ActiveXObject ? new ActiveXObject('Microsoft.XMLHTTP'): null);	return http;	}  	function output() {		if(httpObject.readyState == 4) {			json = httpObject.responseText;			var obj = eval('(' + json + ')');			eval(obj.timer);			document.getElementById('defenderoutput').innerHTML = obj.amount;		}	}	function attack(){			httpObject = getHTTPObject();		if (httpObject != null) {			httpObject.open('GET', 'test.php', true);			httpObject.send(null); 			httpObject.onreadystatechange = output;		}	}</script>

Where I call the output function in the attack function, if I opt out the (), it works. But if I make it output(); I get a "not implemented" error. I looked over the w3schools JavaScript functions page and can't think of whats wrong.

Share this post


Link to post
Share on other sites

When assigning a function to an event you don't use parenthesis, why do you want to do that?

Share this post


Link to post
Share on other sites

Then you can use an anonymous function:

httpObject.onreadystatechange = function() { output("HOLLAH"); }

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...