Click here to Skip to main content
13,046,679 members (72,187 online)
Click here to Skip to main content

Stats

18K views
19 bookmarked
Posted 2 Dec 2010

Observer Pattern in web applications (JavaScript): A walkthrough with an AJAX example

, 2 Dec 2010
Observer pattern is an excellent technique to deal with one to many relationships among objects.
function createXMLHttp(){
        if(window.XMLHttpRequest){
                oXmlHttp= new XMLHttpRequest();
                return oXmlHttp
        } else {
                var aVersions=["MSXML2.XMLHttp.5.0",
                "MSXML2.XMLHttp.4.0","MSXML2.XMLHttp.3.0",
                "MSXML2.XMLHttp","Microsoft.XMLHttp"
                ];

               for(var i=0; i<aVersions.length; i++){
                       try{
                               var oXmlHttpNew=new ActiveXObject(aVersions[i]);
                               oXmlHttp=oXmlHttpNew;
                               return oXmlHttp;
                       } catch(oError) {

                       }
               }
               throw new Error("XMLHttp object could not be created");
        }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Albin Abel
Software Developer
India India
I am developer in .Net and GIS. albin_gis@yahoo.com

You may also be interested in...

Pro
Pro
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170713.1 | Last Updated 2 Dec 2010
Article Copyright 2010 by Albin Abel
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid