Commits

Shu Zong Chen committed 60ad3a1

Added cross-browser xhr

Comments (0)

Files changed (1)

 		endpoint: string representing the url to send data to.
 
 		match: string or RegExp. Pattern to match against filename.
-		       A success means this Reporter will handle the error.
-		       String parameter supports * globbing (is automatically
-		       converted to a RegExp, with `*` converted to .*)
+					 A success means this Reporter will handle the error.
+					 String parameter supports * globbing (is automatically
+					 converted to a RegExp, with `*` converted to .*)
 
 		exclude: Like match, but to test for files you don't want
-		         to handle. Takes precedence over match.
+						 to handle. Takes precedence over match.
 
 		emitter: Not used yet. Will eventually be the type of reporter.
-		         For now it's always a JSON emitter.
+						 For now it's always a JSON emitter.
 
 		extend: A function that returns a array of data to be passed
-		        to the emitter.
+						to the emitter.
 
 		propagate: Whether this Reporter handling an error should
-		           cause the error to stop considering other handlers.
+							 cause the error to stop considering other handlers.
 		*/
 		if (!(this instanceof JER.Reporter)) return new JER.Reporter(spec);
 		this.init(spec);
 	};
 
 	JER.AsyncPOSTEmitter = function(url, data){
-		var req = new XMLHttpRequest();
+		var req = JER.utils.getXMLHttp();
 		req.open('POST', url, true);
 		req.send(data);
 	};
 		};
 		return ret.join("&");
 	};
+	JER.utils.getXMLHttp = function(){
+		if (window.XMLHttpRequest){
+			return new XMLHttpRequest();
+		}
+		if (window.ActiveXObject){
+			var xmlHttp;
+			try {
+				xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
+			}catch(e){
+				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
+			}
+			return xmlHttp;
+		}
+		return false;
+	};
 
 	JER.Reporter._default_spec = {
 		endpoint: null,