Problem with a closure and the return value

M

Martin Honnen

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.
 
B

Börni

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
 
B

Börni

Martin said:
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 ;-)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top