Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

comment on

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

Hey all, I admit that I was a bit under the influence when I posted this yesterday, and to those who may have been offended for it not being Perl related (rightfully so), I apologize. I normally am restrained in making such decisions, but I didn't.

However, because I started this, I'd like it to be concluded. My team lead at work who's very experienced in JS gave me some pointers (I was having issues finding good resources online that put it in a way I easily understood. He explained the whole "callback hell", and in some ways, try to avoid it. Although he gave much better suggestions and pointers than the following, it's what I came up with that I understand to go forward with hacking jquery for the amount I'll need.

I simply call the overarching function on page load, and let it naturally (well, as naturally as JS can be I suppose) handle the whole chain in order. Knowing how jquery/js passes things around, that made it a bit easier to understand.

$(function(){ for(i = 1; i < 4; i++){ var aux = 'aux'+ i; aux_state(aux); } }); function aux_state(aux){ $.get(host +'/get_aux/' + aux, function(state){ $('#'+ aux).switchbutton({ checked: parseInt(state), onChange: function(checked){ $.get(host +'/set_aux/'+ aux +'/'+ checked, functi +on(data){ // do perl stuff }); } }); }); }

Your Mother, because this is a hack job with web UI, my code is all over the map, as I'm just learning. You can find it here on my github. Because I was fudging, you actually have to install the thing (normal steps of installing apply with make), and install some prereqs:

sudo apt-get install sqlite3 cpanm Dancer2; cpanm Dancer2::Plugin::Database

Perhaps others (I haven't properly managed the dependencies while playing around). I then run the app with plackup -R lib,bin,public bin/app.pl, which runs it on port 5000.

Anyways, eventually, it'll be a one-page interface to my Raspberry Pi based indoor grow environment automation control system.


In reply to Re: jQuery issue with Dancer2 by stevieb
in thread jQuery issue with Dancer2 by stevieb

Title:
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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2022-05-28 13:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (99 votes). Check out past polls.

    Notices?