Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Asynchronous in AJAX

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I read a few brief descriptions of AJAX. All of the material showed request/response type samples. How does the Asynchronous part of Ajax work. Let's say I wanted to display a "Times Square" news reader over the top of page. Would this be a good application?

Also, what kind of latency might I expect downloading the Ajax engine? Once downloaded will it be cached somewhere? Plug-in available or needed?
 
Author
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Using the XMLHttpRequest object, we are able to send a request off to the server without interrupting the user. Rather than do a full page repaint, we can get a small chunk of data back and then update the DOM. To me, it's the A in Ajax that makes it particularly interesting to developers. That said, I actually have used XHR to communicate in a synchronous fashion...

News apps are a great spot for Ajax - check out digg. Ajax isn't an engine per-say, it's just taking advantage of new browsers implementing the XMLHttpRequest object. Ajax relies on existing technologies (HTML, DOM, XHR, etc) which are already in the browser - no plugins needed!
 
Terry Milan
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Nate. I think I understand that Ajax doesn't rely on a backend server of any type either. It appears that the data exchanged is fairly raw. I am not familiar with XMLHttpRequest, I am bouncing back and forth to an XMLHttpRequest and Struts and this site trying to get caught up. However, if I were to implement a streaming news reader, for instance, I would rely on native HTTP chunking protocol between my server and Ajax client and I would block in a 'get loop' waiting the next feed? I handle the headers myself? Also, it looking like the document can be very raw, not necessarily XML as the object name implies?
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes you are going to be dealing with passing stuff over HTTP. You are not stuck with the "X" which people think you have to use. You can return strings, javascript statements, (x)html, etc.

What you return is really based on how much processing is needed in the application.

Eric
 
Ranch Hand
Posts: 287
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Eric Pascarello:

What you return is really based on how much processing is needed in the application.



Say, we want to email inbox automatically reflash as new emails come in. In this particular case, which roles are AJAX playing? which roles to let it play would take most advantages of AJAX? Thanks.
 
reply
    Bookmark Topic Watch Topic
  • New Topic