Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Your aux_state() function doesn't return any value. In case you didn't realize, in javascript, 'return' isn't implied like it is in Perl. If that is what you thought, then you also might be assuming that the return value from .get() is the same as the return value from your success function? But I didn't see any mention of a return value from .get() when reading the documentation that I found by searching for jQuery .get.

If JavaScript didn't lack co-routines and so didn't force you into the fragmented code of call-back hell, then you could do something like:

function aux_state(aux){ var returned; $.get(host +'/get_aux/' + aux, function(state){ alert(state); // LINE 2 returned = state; }); return returned; }

And the nature of "call-back hell" infects all of the callers of your function so you probably just can't end up with something that would work for the code you wrote as:

var state = aux_state('aux1');

You likely have to have yet another call-back that would get the fetched state passed to it.

- tye        

In reply to Re: jQuery issue with Dancer2 (return) by tye
in thread jQuery issue with Dancer2 by stevieb

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2022-05-27 21:57 GMT
Find Nodes?
    Voting Booth?
    Do you prefer to work remotely?

    Results (98 votes). Check out past polls.