Welcome!

Open Source Cloud Authors: Pat Romanski, Elizabeth White, Rostyslav Demush, Yeshim Deniz, Harry Trott

Related Topics: Open Source Cloud, Machine Learning

Open Source Cloud: Article

Cross-Browser Client-Side AJAX

Other than using the XMLHTTP request object, how does one go about writing an AJAX application?

Everyone has one or two words or phrases that people associate with them. For example, I always think of my friend Rob eating squid when I hear the words "What do you mean it's not chicken?" Just thinking about those words is enough to transport me through the years to that moment. And the look on his face still makes me smile.

Of course there can be some painful associations too. Like the words "I could code it in about an hour," which will forever remind me of a former manager who was fond of boasting about his prowess as a developer. The fact that he could barely turn a machine on never entered into it. In his mind he was the greatest developer who ever lived and the fact that some tasks took others more than an hour only served to reinforce his belief.

Somewhere between these two poles are the feelings I get when I hear the words "It doesn't blink." That was what the guy kept saying over and over again as I demonstrated an AJAX application. What this person, who remained true to his mainframe roots, was attempting to say was that the page wasn't going through the normal unload/reload cycle.

Because I'm not fond of being kept in the dark myself I made an effort to explain how the application worked. It went something like this: "Instead of using the browser's standard unload/reload cycle to communicate with the Web server client-side JavaScript uses the XMLHTTP request object to communicate directly with the server. This means that less information is passed back and forth so that this kind of application is inherently faster than a traditional Web application. It doesn't 'blink,' as you so put it, because the client-side JavaScript is only updating the parts of the page that changed instead of the whole page."

This was several years ago, years before Jesse James Garrett's AJAX article, and looking back now I suppose I expected too much of most of the people in the room. For some reason I expected immediate acceptance of the application I had written by everyone there. My expectations were dashed when the "it doesn't blink" guy latched on a single phrase like a pit bull, the phrase was, client-side JavaScript.

Because of this phrase, the mainframe developer, still reeling from the job market downturn after Y2K, uttered a phrase of his own in the form of a question, "So, it's a mockup?"

"No, it's communicating with the Web server using client-side JavaScript and the XMLHTTP request object. It's a working application," I replied.

"But it doesn't blink!" he said.

This banter continued for about two hours and would probably still be going on had one user not made a suggestion. He wanted the application to look up a specific item of information. So we did. When the information was displayed in the Web browser, he uttered a remark of his own, "It's not a mockup."

The user elaborated by saying that he had entered the information we displayed five minutes before the meeting began. He earned a glare from the mainframe developer and my undying gratitude.

Until recently scenes like this were pretty much par for the course when demonstrating AJAX applications. But now, since Garrett's AJAX article, everyone wants to jump on the AJAX bandwagon. The rapid adoption of AJAX leaves only one question: other than using the XMLHTTP request object how does one go about writing an AJAX application?

Unfortunately, there's no simple answer, but there's a way to make the question simpler by concentrating on one aspect of it. Look at the problem as putting a Web front-end on a Web Service. So, since we're hip-deep in Web Services - or at least books and articles about how to create Web Services - let's look at creating a pretty front-end for a Web Service.

Because most Web Services use SOAP, the Simple Object Access Protocol, we'll start by looking at the SOAP request:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
   <soap:Body>
     <getItems xmlns="http://tempuri.org/">
       <guild_item_id>string</guild_item_id>
       <guild_id>string</guild_id>
     </getItems>
    </soap:Body>
   </soap:Envelope>

As incomprehensible as the above SOAP request appears to those unfamiliar with the protocol it's actually quite simple. Most of what you see above is a wrapping that identifies it as a SOAP request, essentially any element with the namespace "soap." The stuff that works with the Web Service, getItems, is with the soap:Body tags and it invokes a Web Service named date passing the value "string" in the guild_item_id and guild_id parameters.

All right, now that we know what to send, the next question is how to create an XMLHTTP request object on the client-side to send it to the Web server? This is one of those times when a line in my old resume comes into play. No, not the one about being an escaped mental patient, the one about cross-browser development, which is roughly the same thing. Yes, there's Microsoft's way and then there's everyone else's way.

Why do I feel like I just said a bad word in the pages of LinuxWorld? I feel dirty.

One of the differences between my favorite browser, Firefox, and Internet Explorer is something called ActiveX. Only Microsoft uses it, so it can't be found in Firefox, Flock, or SeaMonkey. And that means that a little more coding is required to consistently create an XMLHTTP request object. What we end up with is code like this:

try {
     objXMLHTTP = new ActiveXObject('Microsoft.XMLHTTP');
}
catch(e) {
     objXMLHTTP = new XMLHttpRequest();
}

Not, bad, but to quote Michael Kane, "What good is a mace if you don't use it?" But before we use it let's take a look at all of the bells and whistles that go along with it (see Table 1).

More Stories By Edmond Woychowsky

Edmond Woychowsky is the author of Prentice Hall's AJAX: Creating Web Pages with Asynchronous JavaScript and XML (to publish August 2006). A graduate of Middlesex Country College and Penn State, Edmond Woychowsky began his professional life at Bell Labs as a dinosaur writing recursive assembly language programs for use in their DOSS order entry system. Throughout his career Ed has worked in the banking, insurance, pharmaceutical and manufacturing industries slowly sprouting feathers and evolving into a web developer. Best known for his often unique articles on the TechRepublic web site as well as his ability to explain how Muenchian grouping works in small words. Currently he can be found working in New Jersey as a consultant, applying both AJAX and XSLT to problems in often bizarre ways and looking forward to his next meal.

Comments (10) View Comments

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


Most Recent Comments
j j 09/30/06 10:45:41 AM EDT

Everyone has one or two words or phrases that people associate with them. For example, I always think of my friend Rob eating squid when I hear the words 'What do you mean it's not chicken?' Just thinking about those words is enough to transport me through the years to that moment. And the look on his face still makes me smile.

j j 09/29/06 01:30:15 PM EDT

Everyone has one or two words or phrases that people associate with them. For example, I always think of my friend Rob eating squid when I hear the words 'What do you mean it's not chicken?' Just thinking about those words is enough to transport me through the years to that moment. And the look on his face still makes me smile.

AJAXWorld News Desk 09/29/06 12:36:33 PM EDT

Everyone has one or two words or phrases that people associate with them. For example, I always think of my friend Rob eating squid when I hear the words 'What do you mean it's not chicken?' Just thinking about those words is enough to transport me through the years to that moment. And the look on his face still makes me smile.

n d 08/27/06 12:20:48 PM EDT

Everyone has one or two words or phrases that people associate with them. For example, I always think of my friend Rob eating squid when I hear the words 'What do you mean it's not chicken?' Just thinking about those words is enough to transport me through the years to that moment. And the look on his face still makes me smile.

n d 08/27/06 12:20:40 PM EDT

Everyone has one or two words or phrases that people associate with them. For example, I always think of my friend Rob eating squid when I hear the words 'What do you mean it's not chicken?' Just thinking about those words is enough to transport me through the years to that moment. And the look on his face still makes me smile.

AJAXWorld News Desk 08/25/06 01:59:15 PM EDT

Everyone has one or two words or phrases that people associate with them. For example, I always think of my friend Rob eating squid when I hear the words 'What do you mean it's not chicken?' Just thinking about those words is enough to transport me through the years to that moment. And the look on his face still makes me smile.

AJAXWorld News Desk 08/25/06 01:58:57 PM EDT

Everyone has one or two words or phrases that people associate with them. For example, I always think of my friend Rob eating squid when I hear the words 'What do you mean it's not chicken?' Just thinking about those words is enough to transport me through the years to that moment. And the look on his face still makes me smile.

AJAXWorld News Desk 08/10/06 01:10:16 PM EDT

Everyone has one or two words or phrases that people associate with them. For example, I always think of my friend Rob eating squid when I hear the words 'What do you mean it's not chicken?' Just thinking about those words is enough to transport me through the years to that moment. And the look on his face still makes me smile.

AJAXWorld News Desk 08/09/06 07:35:49 PM EDT

Everyone has one or two words or phrases that people associate with them. For example, I always think of my friend Rob eating squid when I hear the words 'What do you mean it's not chicken?' Just thinking about those words is enough to transport me through the years to that moment. And the look on his face still makes me smile.

AJAXWorld News Desk 08/04/06 05:20:54 PM EDT

Everyone has one or two words or phrases that people associate with them. For example, I always think of my friend Rob eating squid when I hear the words 'What do you mean it's not chicken?' Just thinking about those words is enough to transport me through the years to that moment. And the look on his face still makes me smile.

@ThingsExpo Stories
Charles Araujo is an industry analyst, internationally recognized authority on the Digital Enterprise and author of The Quantum Age of IT: Why Everything You Know About IT is About to Change. As Principal Analyst with Intellyx, he writes, speaks and advises organizations on how to navigate through this time of disruption. He is also the founder of The Institute for Digital Transformation and a sought after keynote speaker. He has been a regular contributor to both InformationWeek and CIO Insight...
DXWorldEXPO LLC, the producer of the world's most influential technology conferences and trade shows has announced the 22nd International CloudEXPO | DXWorldEXPO "Early Bird Registration" is now open. Register for Full Conference "Gold Pass" ▸ Here (Expo Hall ▸ Here)
Join IBM November 1 at 21st Cloud Expo at the Santa Clara Convention Center in Santa Clara, CA, and learn how IBM Watson can bring cognitive services and AI to intelligent, unmanned systems. Cognitive analysis impacts today’s systems with unparalleled ability that were previously available only to manned, back-end operations. Thanks to cloud processing, IBM Watson can bring cognitive services and AI to intelligent, unmanned systems. Imagine a robot vacuum that becomes your personal assistant tha...
"MobiDev is a software development company and we do complex, custom software development for everybody from entrepreneurs to large enterprises," explained Alan Winters, U.S. Head of Business Development at MobiDev, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
I think DevOps is now a rambunctious teenager - it's starting to get a mind of its own, wanting to get its own things but it still needs some adult supervision," explained Thomas Hooker, VP of marketing at CollabNet, in this SYS-CON.tv interview at DevOps Summit at 20th Cloud Expo, held June 6-8, 2017, at the Javits Center in New York City, NY.
Recently, WebRTC has a lot of eyes from market. The use cases of WebRTC are expanding - video chat, online education, online health care etc. Not only for human-to-human communication, but also IoT use cases such as machine to human use cases can be seen recently. One of the typical use-case is remote camera monitoring. With WebRTC, people can have interoperability and flexibility for deploying monitoring service. However, the benefit of WebRTC for IoT is not only its convenience and interopera...
Cloud-enabled transformation has evolved from cost saving measure to business innovation strategy -- one that combines the cloud with cognitive capabilities to drive market disruption. Learn how you can achieve the insight and agility you need to gain a competitive advantage. Industry-acclaimed CTO and cloud expert, Shankar Kalyana presents. Only the most exceptional IBMers are appointed with the rare distinction of IBM Fellow, the highest technical honor in the company. Shankar has also receive...
It is of utmost importance for the future success of WebRTC to ensure that interoperability is operational between web browsers and any WebRTC-compliant client. To be guaranteed as operational and effective, interoperability must be tested extensively by establishing WebRTC data and media connections between different web browsers running on different devices and operating systems. In his session at WebRTC Summit at @ThingsExpo, Dr. Alex Gouaillard, CEO and Founder of CoSMo Software, presented ...
WebRTC is great technology to build your own communication tools. It will be even more exciting experience it with advanced devices, such as a 360 Camera, 360 microphone, and a depth sensor camera. In his session at @ThingsExpo, Masashi Ganeko, a manager at INFOCOM Corporation, introduced two experimental projects from his team and what they learned from them. "Shotoku Tamago" uses the robot audition software HARK to track speakers in 360 video of a remote party. "Virtual Teleport" uses a multip...
Business professionals no longer wonder if they'll migrate to the cloud; it's now a matter of when. The cloud environment has proved to be a major force in transitioning to an agile business model that enables quick decisions and fast implementation that solidify customer relationships. And when the cloud is combined with the power of cognitive computing, it drives innovation and transformation that achieves astounding competitive advantage.
Data is the fuel that drives the machine learning algorithmic engines and ultimately provides the business value. In his session at Cloud Expo, Ed Featherston, a director and senior enterprise architect at Collaborative Consulting, discussed the key considerations around quality, volume, timeliness, and pedigree that must be dealt with in order to properly fuel that engine.
IoT is rapidly becoming mainstream as more and more investments are made into the platforms and technology. As this movement continues to expand and gain momentum it creates a massive wall of noise that can be difficult to sift through. Unfortunately, this inevitably makes IoT less approachable for people to get started with and can hamper efforts to integrate this key technology into your own portfolio. There are so many connected products already in place today with many hundreds more on the h...
When shopping for a new data processing platform for IoT solutions, many development teams want to be able to test-drive options before making a choice. Yet when evaluating an IoT solution, it’s simply not feasible to do so at scale with physical devices. Building a sensor simulator is the next best choice; however, generating a realistic simulation at very high TPS with ease of configurability is a formidable challenge. When dealing with multiple application or transport protocols, you would be...
Detecting internal user threats in the Big Data eco-system is challenging and cumbersome. Many organizations monitor internal usage of the Big Data eco-system using a set of alerts. This is not a scalable process given the increase in the number of alerts with the accelerating growth in data volume and user base. Organizations are increasingly leveraging machine learning to monitor only those data elements that are sensitive and critical, autonomously establish monitoring policies, and to detect...
In his keynote at 18th Cloud Expo, Andrew Keys, Co-Founder of ConsenSys Enterprise, provided an overview of the evolution of the Internet and the Database and the future of their combination – the Blockchain. Andrew Keys is Co-Founder of ConsenSys Enterprise. He comes to ConsenSys Enterprise with capital markets, technology and entrepreneurial experience. Previously, he worked for UBS investment bank in equities analysis. Later, he was responsible for the creation and distribution of life settl...
In his session at @ThingsExpo, Dr. Robert Cohen, an economist and senior fellow at the Economic Strategy Institute, presented the findings of a series of six detailed case studies of how large corporations are implementing IoT. The session explored how IoT has improved their economic performance, had major impacts on business models and resulted in impressive ROIs. The companies covered span manufacturing and services firms. He also explored servicification, how manufacturing firms shift from se...
DevOpsSummit New York 2018, colocated with CloudEXPO | DXWorldEXPO New York 2018 will be held November 11-13, 2018, in New York City. Digital Transformation (DX) is a major focus with the introduction of DXWorldEXPO within the program. Successful transformation requires a laser focus on being data-driven and on using all the tools available that enable transformation if they plan to survive over the long term. A total of 88% of Fortune 500 companies from a generation ago are now out of bus...
The Jevons Paradox suggests that when technological advances increase efficiency of a resource, it results in an overall increase in consumption. Writing on the increased use of coal as a result of technological improvements, 19th-century economist William Stanley Jevons found that these improvements led to the development of new ways to utilize coal. In his session at 19th Cloud Expo, Mark Thiele, Chief Strategy Officer for Apcera, compared the Jevons Paradox to modern-day enterprise IT, examin...
IoT solutions exploit operational data generated by Internet-connected smart “things” for the purpose of gaining operational insight and producing “better outcomes” (for example, create new business models, eliminate unscheduled maintenance, etc.). The explosive proliferation of IoT solutions will result in an exponential growth in the volume of IoT data, precipitating significant Information Governance issues: who owns the IoT data, what are the rights/duties of IoT solutions adopters towards t...
Amazon started as an online bookseller 20 years ago. Since then, it has evolved into a technology juggernaut that has disrupted multiple markets and industries and touches many aspects of our lives. It is a relentless technology and business model innovator driving disruption throughout numerous ecosystems. Amazon’s AWS revenues alone are approaching $16B a year making it one of the largest IT companies in the world. With dominant offerings in Cloud, IoT, eCommerce, Big Data, AI, Digital Assista...