Slashdot Mirror


Asynchronous Requests with JavaScript and Ajax

An anonymous reader writes "I rarely read an entire article about a single object, especially one that is this simple. However, you will use this object over and over again in each page and application that you write that uses Ajax. This article shows you how to create XMLHttpRequest instances in a cross-browser way, construct and send requests, and respond to the server."

5 of 178 comments (clear)

  1. IBM articles; Security with Javascript by WebHostingGuy · · Score: 2, Interesting

    While slightly off-topic, I do have to say that IBM's articles are some of the best on the net. They have very good writers and can explain things without resorting to techno-babble for the layman.

    On another note, it seems that the current flavor of the month is Ajax. However, this requires that javascript be enabled. Is anyone running into the problem of finding a lot of users are forgoing this technology because they have (or have been told by their company) to disable javascript for security concerns?

    --
    Quality Hosting e3 Servers
    1. Re:IBM articles; Security with Javascript by masklinn · · Score: 4, Interesting

      I usually consider that 10% of the users have javascript partially or fully disabled either because they use javascript-less browsers (rare) or because of security issues (corporate environments). The trick there is to develop your web application with the Progressive Enhancements philosophy in mind: build a layered, Javascript/AJAX is merely a client-side behavioural layer added on top of the content layer (pure HTML) and the style layer (CSS), it relies on both but shouldn't be necessary for the application itself to work. It's merely applying the good ol' layers separation on your client-side web pages.

      Following the Progressive Enhancements "way" raises the chances that your websites will degrade fairly gracefully when the upper layers are not available (old browser, quirks, ...) without "shutting down" the whole site for the user (or lower the cost/pain of having them degrade gracefully).

      --
      "The way we can tell it's C# instead of Haskell is because it's nine lines instead of two." -- wadler
  2. Re:If you like this, try too AJAX Developer's Jour by kurth · · Score: 3, Interesting

    My honest first impression was that ti was a spyware site, you know, the ones that look useful, but are really just there for the sake of serving ads?

  3. Re:Hello world by KiloByte · · Score: 2, Interesting

    Actually, I thought they mean a way how to have it truly asynchronous -- ie, without building a whole TCP connection first, getting acks and what not. But no, this is just the very basic XMLHttpRequest.

    So, would anyone be able to tell me how to send something to a server using a single half-trip? It may be a part of a persistent connection, any eventual ack can be sent through a separate channel, I don't really care about bandwidth -- all that matters is the latency between the user's action and the time server receives the command. Think "interactive app", where interaction means something faster than a matter of seconds.

    The only way I can think of so far is trying to send dummy requests to command.1.is.foo.dns.my.server and have the DNS relay me these; however, this would be an insanely ugly hack. Any better ideas?

    --
    The creatures outside looked from Alt-Right to Antifa; but already it was impossible to say which was which.
  4. Re:Hello world by mrchaotica · · Score: 2, Interesting

    Quick question for you: If you only need a "half-trip," how could latency possibly matter? Since it's not waiting for a response from the server, there's no way the client could possibly know how long the request took!

    If you throw away a can, does it matter how long it takes to get to the recycling center?

    --

    "[Regarding the 'cloud,'] ownership was what made America different than Russia." -- Woz