JavaScript
  Home arrow JavaScript arrow Ajax Hack for Entering Information Without...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
JAVASCRIPT

Ajax Hack for Entering Information Without Refreshing Your Browser
By: O'Reilly Media
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 3
    2008-07-10

    Table of Contents:
  • Ajax Hack for Entering Information Without Refreshing Your Browser
  • Web Forms
  • Event Handler Code
  • Get the First Serve In

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Ajax Hack for Entering Information Without Refreshing Your Browser


    (Page 1 of 4 )

    Ajax improves the web experience by letting users interact with web sites more quickly and intuitively. With Ajax properly set up on a web site, a user can enter a comment and see it appear on the site without waiting for their browser to refresh. This article will explain how to accomplish this bit of online magic. It is excerpted from chapter 12 of the book Ajax Hacks, written by Bruce W. Perry (O'Reilly; ISBN: 0596101694). Copyright © 2007 O'Reilly Media, Inc. All rights reserved. Used with permission from the publisher. Available from booksellers or direct from O'Reilly Media.

    Hack 12  Submit Text Field or textarea Values to the Server Without a Browser Refresh

    Create a smooth transition between entering information into a textarea or text field and instantly transferring the data to the server.

    Ajax applications can automatically send to a server program the information that the user has entered into a text field ortextarea. The application code waits for the text widget’sonblurevent to occur, then uses the request object to send just the data from that field ortextarea. In many applications, this technique is preferable to requiring the user to click a Submit button, then sending all of the form’s values to the server in a big clump. It is also much snappier in terms of the application’s responsiveness. For example, an online quiz or teaching application can fetch and display the correct answer to a question as soon as the user has moved away from the field, instead of requiring the user to click a button and refresh the page just to see specific answers. Real-time language translation is another possible application for this user-interface behavior.

    The onblur event is triggered when a web form control such as a text field loses the keyboard focus, which is typically caused by the user pressing the Tab key or clicking outside of the field. You can also use the onkeypress, onkeydown, or onkeyup event handlers to respond to user interaction with a text widget.

    Here is this hack’s sequence of events for sending text to the server:

    1. The user tabs into the field or clicks in atextarea.
    2. The user types some text.
    3. The user then presses Tab or clicks on another part of the page to exit the text field ortextarea.

    One issue with intervention-less form sending is that users are not accustomed to this kind of behavior from web forms. A user might be put off or confused by web-form controls such as text fields that dynamically submit their own data. The user interface should make it clear that “something is going to happen” when the user is finished with the text field, or display a message or progress indicator when the request object is sending the data. In addition, depending on the sensitivity of the task, you may want to add another layer of communication with the user, such as analertwindow asking “Are you sure you want to submit the information?”

    More JavaScript Articles
    More By O'Reilly Media


       · This article is an excerpt from the book "Ajax Hacks," published by O'Reilly. We...
     

    Buy this book now. This article is excerpted from chapter 12 of the book Ajax Hacks, written by Bruce W. Perry (O'Reilly; ISBN: 0596101694). Check it out today at your favorite bookstore. Buy this book now.

    JAVASCRIPT ARTICLES

    - Using Click Interceptions with a Database-Dr...
    - Using JavaScript Click Interceptions in an I...
    - Using Click Interceptions with JavaScript
    - QuickSort in Action
    - Quicksort
    - Using Mod_Security to Protect Your Server
    - Detecting and Countering Server Intrusions
    - Securing Your Web Server
    - Building a Secure Web Server
    - Protecting the Server
    - Book Review: Learning the Yahoo! User Interf...
    - Dynamically Generate a Selection List in a R...
    - Intergrate DWR into Your Java Web Application
    - Detect Browser Compatibility with the Reques...
    - Using the EXT JS Date Picker Widget






    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
    Stay green...Green IT