Problem with a closure and the return value

Discussion in 'Javascript' started by Martin Honnen, Dec 23, 2004.

  1. 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/
    Martin Honnen, Dec 23, 2004
    #1
    1. Advertising

  2. Martin Honnen

    Börni Guest

    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örni, Dec 23, 2004
    #2
    1. Advertising

  3. Martin Honnen

    Börni Guest

    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 ;-)
    Börni, Dec 23, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John J. Lee
    Replies:
    4
    Views:
    361
    John J. Lee
    Nov 8, 2003
  2. Huayang Xia
    Replies:
    11
    Views:
    459
    Fredrik Lundh
    Dec 19, 2006
  3. Greenhorn
    Replies:
    15
    Views:
    800
    Keith Thompson
    Mar 6, 2005
  4. Replies:
    4
    Views:
    239
  5. Julian Mehnle
    Replies:
    0
    Views:
    229
    Julian Mehnle
    Jul 17, 2003
Loading...

Share This Page