Jump to content

XMLHttpRequest.onreadystatechange = function()


Recommended Posts

So I tried implementing ajax by using a lambda function - failing horribly.

Why can I not pass into the onreadystatechange property a callback function that behaves in a similar manner to that of one that is passed as an argument? Is this some sort of syntax of JS that I am not aware of ?

alert(function(){return "Hello!";});//worksXMLHttpRequestObject.onreadystatechange = function(){alert("hello";)};//does not work
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...