From: Kevin Carhart <kevin@carhart.net>
To: Karl Dahlke <eklhad@comcast.net>
Cc: Edbrowse-dev@lists.the-brannons.com
Subject: Re: [Edbrowse-dev] $ object in javascript
Date: Tue, 29 Nov 2016 16:47:03 -0800 (PST) [thread overview]
Message-ID: <alpine.LRH.2.03.1611291619100.9088@carhart.net> (raw)
In-Reply-To: <20161029110356.eklhad@comcast.net>
Hi Karl and company,
$.get is a wrapper around an HTTP get. So the page code loads a version
of jquery, which includes a get method someplace within it. When the page
code calls this, it will want to work with XMLHttpRequest supplied by the
DOM. So it goes to our XMLHttpRequest code in startwindow, or should.
>From there, it calls our native method for inline HTTP requests, in
jseng-moz.cpp. It can
then fire the request, get some html, send it back to startwindow, and
from startwindow send it back to the page's code. When it says
function (data) { ...
, this is a handler that specifies what it will do with the HTML
that is returned. It could do particular DOM splices, put the response
into a div, or stuff like that. I am not sure if it is formally correct
to call it a callback, but that's the idea.
So the pieces are there, but it has not been exercised
that much. When I was trying to get the drescher site working, it was a
cycle like this and in some cases it worked. So the good news is that
the intentions of this snippet represent a common thing to want to do, so
effort we put into it will pay off.
Here's a paraphrase of the entire snippet. Yes, as Chris says, the $ is
just an alias for the jQuery object. It tests for the presence of a
certain table which is subsidiary to the node scheduled_top15s. If not
found... if (not ( blah blah expression has length) ...
you go grab it inline, using GET,
and once you have it, you follow the instructions in the handler, so in
this case it populates the innerhtml of scheduled_top15s with the
dynamically retrieved tags. And our native C++ will handle
this, which is very cool!
At this point, whatever code follows can rely on that thing existing
because you either verified its presence or grabbed it using GET.
>
> if(!$("#scheduled_top15s").find("table").length){
> $.get("php/get_scheduled_top15s_public_2.php", function( data ) {
> $("#scheduled_top15s").html( data );
> });
> }
>
next prev parent reply other threads:[~2016-11-30 0:46 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-29 16:03 Karl Dahlke
2016-11-29 16:24 ` Chris Brannon
2016-11-30 0:47 ` Kevin Carhart [this message]
2016-11-30 7:30 ` Karl Dahlke
2016-11-30 7:43 ` Tyler Spivey
2016-11-30 7:54 ` Karl Dahlke
2016-12-01 0:04 ` Kevin Carhart
2016-12-01 1:17 ` Karl Dahlke
2016-12-25 13:06 ` Adam Thompson
2016-12-26 14:52 ` Karl Dahlke
2016-12-27 3:04 ` Kevin Carhart
2016-12-27 3:49 ` Karl Dahlke
2016-12-27 4:17 ` Kevin Carhart
2016-12-27 4:38 ` Karl Dahlke
2016-12-27 18:37 ` Adam Thompson
2016-12-27 4:59 ` Chris Brannon
2016-12-27 6:53 ` Kevin Carhart
2016-12-27 15:21 ` Chris Brannon
2016-12-27 20:13 ` Kevin Carhart
2016-12-27 13:26 ` Karl Dahlke
2016-12-27 15:47 ` Chris Brannon
2016-12-27 18:48 ` Adam Thompson
2016-12-27 20:23 ` Chris Brannon
2016-12-28 11:42 ` [Edbrowse-dev] Edbrowse in NetBSD Adam Thompson
2016-12-28 11:50 ` Chris Brannon
2016-12-28 12:15 ` Adam Thompson
2016-12-27 19:11 ` [Edbrowse-dev] $ object in javascript Adam Thompson
2016-12-27 19:47 ` Kevin Carhart
2016-12-27 20:11 ` Karl Dahlke
2016-12-27 20:45 ` [Edbrowse-dev] nextSibling and previousSibling Kevin Carhart
2016-12-27 21:14 ` Chris Brannon
2016-12-28 11:38 ` [Edbrowse-dev] $ object in javascript Adam Thompson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.LRH.2.03.1611291619100.9088@carhart.net \
--to=kevin@carhart.net \
--cc=Edbrowse-dev@lists.the-brannons.com \
--cc=eklhad@comcast.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).