471,350 Members | 1,586 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,350 software developers and data experts.

Problem with a closure and the return value

Hi,

i want to do something like that:

this.xmlhttp.onreadystatechange = return (function () {
if (myRequest.readyState === 4) {
return myRequest.responseText;
}
});

But i just get an Syntax error. How else could i return the responseText?

Greetings
Jul 23 '05 #1
2 2494


Börni wrote:

i want to do something like that:

this.xmlhttp.onreadystatechange = return (function () {
if (myRequest.readyState === 4) {
return myRequest.responseText;
}
});

But i just get an Syntax error. How else could i return the responseText?


Well with event based programming you can't return a value from the
onreadystatechange event handler, you need to somehow set that up
differently, the onreadystatechange event handler could call a function
and pass the responseText to it.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #2
Martin Honnen wrote:

Well with event based programming you can't return a value from the
onreadystatechange event handler, you need to somehow set that up
differently, the onreadystatechange event handler could call a function
and pass the responseText to it.


Ok, thanx.

You are a real quick guy ;-)
Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Dave Benjamin | last post: by
27 posts views Thread by Ted Lilley | last post: by
7 posts views Thread by Csaba Gabor | last post: by
reply views Thread by Gerard Brunick | last post: by
11 posts views Thread by Huayang Xia | last post: by
7 posts views Thread by abs | last post: by
2 posts views Thread by jman | last post: by
3 posts views Thread by disappearedng | last post: by
reply views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.