AJAX without Rails

Hassan S. wrote:

On Tue, Mar 18, 2008 at 1:51 PM, Tony De [email protected] wrote:

   ......................... it seems that all the page magic is coded into the

web page itself. I didn’t see any info (perhaps that’s not how JQuery
works) on accessing the DOM elements from a cgi or ruby code.

That’s not how it works, period. JavaScript running in the browser
sends a request to a server process, which returns a response; it’s
up to the in-page JS to handle the response appropriately.

But there’s no way for the server to directly manipulate anything on
the client.

@ Hassan,

Ok, I get that part.
So, for example, looking at the examples on the JQuery website. When I
look at the source or any of the example page demos, which as I
understand it is using AJAX, I don’t see any call to an external script.
It appears it is handling things locally, perhaps sending the request to
the “local” AJAX server, but not a a server script (say cgi) and the
script sending a request back to the AJAX server on the client.

tonyd

Hassan S. wrote:

On Tue, Mar 18, 2008 at 3:02 PM, Tony De [email protected] wrote:

So, for example, looking at the examples on the JQuery website. When I
look at the source or any of the example page demos, which as I
understand it is using AJAX, I don’t see any call to an external script.

Then you haven’t actually found any AJAX examples. JQuery is a
library of functions, not all of which have anything to do with AJAX.

It appears it is handling things locally, perhaps sending the request to
the “local” AJAX server, but not a a server script (say cgi) and the
script sending a request back to the AJAX server on the client.

There is no “local” or “client” AJAX server. There’s the client where
the JS is running, and the server the page was loaded from, which
can also serve AJAX requests.

I don’t use JQuery, but there’s gotta be some examples there :slight_smile:

Thanks Hassan, I’ll keep searching…

tonyd

Have to agree with the one writing about some replies ago, in that
Michael N.'s example is very beautiful IMO.

Tony De wrote:

Hassan S. wrote:

I don’t use JQuery, but there’s gotta be some examples there :slight_smile:

Thanks Hassan, I’ll keep searching…

You should dig up a tutorial on the XmlHttpRequest object.

It is not the only way to do this sort of thing, but is likely the most
common. It’s not complicated.

Basically, some javascript running in the browser makes a request of a
URL. What gets returned from the server is (typically) used to alter
the browser DOM.

There are, I believe, some examples of this shipped with the Ramaze
source code.

www.ramaze.net


James B.

“Judge a man by his questions, rather than his answers.”

  • Voltaire

From: James B. [mailto:[email protected]]

www.ramaze.net

ah, the mention of that humble big little framework called ramaze makes
me smile; lightweight, open, multiple engines, helpers, templates, and
very rubyish, even rubyish than ruby’s webrick, imho. ruby amaze-ing
indeed :slight_smile:

kind regards -botp

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs