Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Problem with a closure and the return value

Reply
Thread Tools

Problem with a closure and the return value

 
 
Martin Honnen
Guest
Posts: n/a
 
      12-23-2004


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/
 
Reply With Quote
 
 
 
 
Börni
Guest
Posts: n/a
 
      12-23-2004
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
 
Reply With Quote
 
 
 
 
Börni
Guest
Posts: n/a
 
      12-23-2004
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
When Closure get external variable's value? Huayang Xia Python 11 12-19-2006 10:36 PM
what value does lack of return or empty "return;" return Greenhorn C Programming 15 03-06-2005 08:19 PM
problem with closure arguments and *args in mock object John J. Lee Python 4 11-08-2003 12:28 PM
Return a return value from Perl to Javascript PvdK Perl 0 07-24-2003 09:20 AM
Perl hangs when returning lvalue closure from another lvalue closure Julian Mehnle Perl Misc 0 07-17-2003 03:13 PM



Advertisments