Logo

Navigation
  • Home
  • Services
    • ERP Solutions
    • Implementation Solutions
    • Support and Maintenance Solutions
    • Custom Solutions
    • Upgrade Solutions
    • Training and Mentoring
    • Web Solutions
    • Production Support
    • Architecture Designing
    • Independent Validation and Testing Services
    • Infrastructure Management
  • Expertise
    • Microsoft Development Expertise
    • Mobile Development
    • SQL Server Database and BI
    • SAP BI, SAP Hana, SAP BO
    • Oracle and BI
    • Oracle RAC
  • Technical Training
    • Learn Data Management
      • Business Intelligence
      • Data Mining
      • Data Modeling
      • Data Warehousing
      • Disaster Recovery
    • Learn Concepts
      • Application Development
      • Client Server
      • Cloud Computing Tutorials
      • Cluster Computing
      • CRM Tutorial
      • EDI Tutorials
      • ERP Tutorials
      • NLP
      • OOPS
      • Concepts
      • SOA Tutorial
      • Supply Chain
      • Technology Trends
      • UML
      • Virtualization
      • Web 2.0
    • Learn Java
      • JavaScript Tutorial
      • JSP Tutorials
      • J2EE
    • Learn Microsoft
      • MSAS
      • ASP.NET
      • ASP.NET 2.0
      • C Sharp
      • MS Project Training
      • Silverlight
      • SQL Server 2005
      • VB.NET 2005
    • Learn Networking
      • Networking
      • Wireless
    • Learn Oracle
      • Oracle 10g
      • PL/SQL
      • Oracle 11g Tutorials
      • Oracle 9i
      • Oracle Apps
    • Learn Programming
      • Ajax Tutorial
      • C Language
      • C++ Tutorials
      • CSS Tutorial
      • CSS3 Tutorial
      • JavaScript Tutorial
      • jQuery Tutorial
      • MainFrame
      • PHP Tutorial
      • VBScript Tutorial
      • XML Tutorial
    • Learn Software Testing
      • Software Testing Types
      • SQA
      • Testing
  • Career Training
    • Career Improvement
      • Career Articles
      • Certification Articles
      • Conflict Management
      • Core Skills
      • Decision Making
      • Entrepreneurship
      • Goal Setting
      • Life Skills
      • Performance Development
      • Personal Excellence
      • Personality Development
      • Problem Solving
      • Relationship Management
      • Self Confidence
      • Self Supervision
      • Social Networking
      • Strategic Planning
      • Time Management
    • Education Help
      • Career Tracks
      • Essay Writing
      • Internship Tips
      • Online Education
      • Scholarships
      • Student Loans
    • Managerial Skills
      • Business Communication
      • Business Networking
      • Facilitator Skills
      • Managing Change
      • Marketing Management
      • Meeting Management
      • Process Management
      • Project Management
      • Project Management Life Cycle
      • Project Management Process
      • Project Risk Management
      • Relationship Management
      • Task Management
      • Team Building
      • Virtual Team Management
    • Essential Life Skills
      • Anger Management
      • Anxiety Management
      • Attitude Development
      • Coaching and Mentoring
      • Emotional Intelligence
      • Stress Management
      • Positive Thinking
    • Communication Skills
      • Conversation Skills
      • Cross Culture Competence
      • English Vocabulary
      • Listening Skills
      • Public Speaking Skills
      • Questioning Skills
    • Soft Skills
      • Assertive Skills
      • Influence Skills
      • Leadership Skills
      • Memory Skills
      • People Skills
      • Presentation Skills
    • Finding a Job
      • Etiquette Tips
      • Group Discussions
      • HR Interviews
      • Interview Notes
      • Job Search Tips
      • Resume Tips
      • Sample Resumes
 

Introduction to Ajax

By Exforsys | on June 13, 2006 |
Ajax Tutorial

Introduction to Ajax

Last time we looked at Web 2.0 and what differentiates it from older paradigms for Internet products. One of the differentiators is the use of Rich Client Interfaces. Ajax is possibly the most popular Rich Client technology and used in such applications as Google Maps and Google Mail.

Ajax is an acronym for “Asynchronous JavaScript And XML.” Web pages are endowed with snippets of code that can access remote services (like web services) and not refresh the page. This prevents “round tripping” which is the cause for display flicker and slow response times.

The techniques used in Ajax applications are not new. For the most part Ajax is similar to Dynamic HTML (DHTML). One major feature that Ajax applications use is the XMLHttpRequest object. This allows access to remote services either synchronously or asynchronously.

The following code sample is an HTML page with JavaScript to call out to a PHP page which returns a random number:

Run Sample

Download Sample Code

Functions used :

  1. function makeCall() { request = new ActiveXObject("Microsoft.XMLHTTP"); if (request) { var now = new Date(); request.onreadystatechange = updateMe; request.open("GET", "ajax1b.php?nocache="+now.getTime(), true); request.send(null); } }  function updateMe() { if (request.readyState != 4) return; if (request.status != 200) return; document.getElementById("result").value = request.responseText; request.abort(); request = null; }

The salient feature of this code sample is the creation of the XMLHttpRequest object:

request = new ActiveXObject("Microsoft.XMLHTTP");

This is the Internet Explorer version. In a future article we’ll explore how to make the JavaScript more browser agnostic. Once created, the request can open a connection. The “open” command indicates that we’re doing a “GET” operation and specifies the URL of the resource we want to get (our short PHP program to generate a random number). Finally, the last parameter indicates whether this is an asynchronous call.

There is a known problem with the Microsoft version of the XMLHttpRequest object: it caches the resource. This is “fixed” by appending a parameter to the request that is the current time in milliseconds. This is fairly certain to create a unique request. This is clearly a hack and I am still researching a better fix for it.

The next salient feature is:

request.onreadystatechange = updateMe

which indicates which method to call when the resource returns its value. In this case we are calling the “updateMe()” method.

Finally, the request is sent and control is returned to the caller. When the request is satisfied, “updatMe()” is called and the TextArea is updated with the returned random number.

Notice that at no time did we redisplay the ajax1a.html page. Everything was handled in JavaScript.

This method of operating is very valuable. It means that one can put all the business logic of the application in “back end” code and all the display logic in the web page. One can even do validation on the back end and return status to the front end. This solves a significant problem in the design of n-tiered systems. “Separation of Concerns” dictates that we keep our display logic in the web pages and our business logic in the back end. However, validation is actually a function of business logic. Using a web service for validation, it can be kept in the back end where it properly belongs.

Ajax code can be very complicated to write. There is a lot of code that has to be created to make the application browser agnostic. To truly take advantage of the promise of Rich Clients in general and Ajax in particular, you need a library of widgets and support functions.

Next time, we’ll look at a more complete example using XML and true web services. Later articles will look at some of the libraries that are emerging in support of Ajax programming.

Author : Greg Smith

« « Introduction to Web 2.0
XML – Document Type Definitions (DTD) » »

Author Description

Avatar

Editorial Team at Exforsys is a team of IT Consulting and Training team led by Chandra Vennapoosa.

Free Training

RSSSubscribe 394 Followers
  • Popular
  • Recent
  • How Ajax Has Become More Standardized

    March 26, 2007 - 0 Comment
  • How Ajax Can Improve Web Applications

    March 29, 2007 - 0 Comment
  • How Ajax Can Become as User Friendly as Flash

    March 30, 2007 - 0 Comment
  • Ajax Graphics Enhancement Tools

    April 5, 2007 - 0 Comment
  • Ajax, Web Services & XML Part I

    July 16, 2006 - 0 Comment
  • The Power of Ajax

    April 16, 2007 - 0 Comment
  • Ajax, Web Services & XML Part II

    July 16, 2006 - 0 Comment
  • Making Ajax Accessible

    March 14, 2007 - 0 Comment
  • Ajax Challenges

    March 14, 2007 - 0 Comment
  • Ajax Framework

    March 17, 2007 - 0 Comment
  • The Power of Ajax

    April 16, 2007 - 0 Comment
  • Ajax Graphics Enhancement Tools

    April 5, 2007 - 0 Comment
  • How Ajax Can Become as User Friendly as Flash

    March 30, 2007 - 0 Comment
  • How Ajax Can Improve Web Applications

    March 29, 2007 - 0 Comment
  • How Ajax Has Become More Standardized

    March 26, 2007 - 0 Comment
  • Advantages and Disadvantages of Ajax

    March 24, 2007 - 0 Comment
  • The Security Aspects of Ajax

    March 22, 2007 - 0 Comment
  • Ajax Framework

    March 17, 2007 - 0 Comment
  • Ajax Challenges

    March 14, 2007 - 0 Comment
  • Making Ajax Accessible

    March 14, 2007 - 0 Comment

Exforsys e-Newsletter

ebook
 

Related Articles

  • The Power of Ajax
  • Ajax Graphics Enhancement Tools
  • How Ajax Can Become as User Friendly as Flash
  • How Ajax Can Improve Web Applications
  • How Ajax Has Become More Standardized

Latest Articles

  • Project Management Techniques
  • Product Development Best Practices
  • Importance of Quality Data Management
  • How to Maximize Quality Assurance
  • Utilizing Effective Quality Assurance Strategies
  • Sitemap
  • Privacy Policy
  • DMCA
  • Trademark Information
  • Contact Us
© 2023. All Rights Reserved.IT Training and Consulting
This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish.AcceptReject Read More
Privacy & Cookies Policy

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Non-necessary
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
SAVE & ACCEPT