mobone Posted June 30, 2009 Share Posted June 30, 2009 <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. Link to comment Share on other sites More sharing options...
Ingolme Posted June 30, 2009 Share Posted June 30, 2009 When assigning a function to an event you don't use parenthesis, why do you want to do that? Link to comment Share on other sites More sharing options...
Synook Posted June 30, 2009 Share Posted June 30, 2009 http://en.wikipedia.org/wiki/Prototype-based_programming Link to comment Share on other sites More sharing options...
mobone Posted June 30, 2009 Author Share Posted June 30, 2009 When assigning a function to an event you don't use parenthesis, why do you want to do that?I want to pass name to output. Link to comment Share on other sites More sharing options...
jesh Posted June 30, 2009 Share Posted June 30, 2009 Then you can use an anonymous function: httpObject.onreadystatechange = function() { output("HOLLAH"); } Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.