From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out.smtp-auth.no-ip.com (out.smtp-auth.no-ip.com [8.23.224.60]) by hurricane.the-brannons.com (Postfix) with ESMTPS id C17DA77D01 for ; Tue, 29 Nov 2016 16:46:47 -0800 (PST) X-No-IP: carhart.net@noip-smtp X-Report-Spam-To: abuse@no-ip.com Received: from carhart.net (unknown [99.52.200.227]) (Authenticated sender: carhart.net@noip-smtp) by smtp-auth.no-ip.com (Postfix) with ESMTPA id C572D3CF; Tue, 29 Nov 2016 16:47:04 -0800 (PST) Received: from carhart.net (localhost [127.0.0.1]) by carhart.net (8.13.8/8.13.8) with ESMTP id uAU0l3Zu011734; Tue, 29 Nov 2016 16:47:03 -0800 Received: from localhost (kevin@localhost) by carhart.net (8.13.8/8.13.8/Submit) with ESMTP id uAU0l31T011727; Tue, 29 Nov 2016 16:47:03 -0800 Date: Tue, 29 Nov 2016 16:47:03 -0800 (PST) From: Kevin Carhart To: Karl Dahlke cc: Edbrowse-dev@lists.the-brannons.com In-Reply-To: <20161029110356.eklhad@comcast.net> Message-ID: References: <20161029110356.eklhad@comcast.net> User-Agent: Alpine 2.03 (LRH 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Subject: Re: [Edbrowse-dev] $ object in javascript X-BeenThere: edbrowse-dev@lists.the-brannons.com X-Mailman-Version: 2.1.23 Precedence: list List-Id: Edbrowse Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Nov 2016 00:46:47 -0000 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 ); > }); > } >