Fav XMLHttpRequest function

	var request = null;
	function InitAJAX()
	{
	    var objxml = null;
	    var ProgID = ["Msxml2.XMLHTTP.6.0", "Msxml2.XMLHTTP.3.0","Msxml2.XMLHTTP", "Microsoft.XMLHTTP"];            

	    try {
	        objxml = new XMLHttpRequest();
	    }
	    catch(e) {
	        for (var i = 0; i < ProgID.length; i++){
	            try {
	                objxml = new ActiveXObject(ProgID[i]);
	            }
	            catch(e) {
	                continue;
	            }
	        }
	    }
	    return objxml;
	}

Usage:

request = InitAJAX();
// Do useful stuf with request


Comments

No comments yet.

Add Yours

  • Author Avatar

    YOU


Comment Arrow



About Author

Sirbastian

Probably the best web developer in the whole world.