;(function(root){var LD = function(obj){if( obj instanceof LD ) returnobj;if( !(this instanceof LD )) return newLD(obj);
};
root.LD=LD;
console.log(window.LD);function__encodeParameter( data ){
let tmp= "";if(typeof data === 'string')
tmp=data;else{var e =encodeURIComponent;var params =[];for( let k indata ){if(data.hasOwnProperty( k )){
params.push( e(k))+'=' +e(data[k]);
}
}
tmp= params.join('&') ; //}returntmp;
}function__initialize_xhr(){
let xhr ;if(window.XMLHttpRequest){
xhr= newXMLHttpRequest();
}else if(window.ActiveXObject){try{
xhr= new ActiveXObject("Msxml2.XMLHTTP");
}catch(ex){
console.log(ex);
xhr= new ActiveXObject("Microsoft.XMLHTTP");
}
}returnxhr;
}var ajax = LD.Ajax = function( method , url , data , headers ,cb){
let promise= new Promise(function(resolve , reject ){
let xhr , params;
data= data ||{};
headers= headers ||{};try{
xhr=__initialize_xhr();
}catch(ex){
console.log(ex);
}
params=__encodeParameter( data );
console.log("-------"+params);if(method == 'GET' &¶ms ){
url+= '?' +params;
params= null;
}
xhr.open( method , url );var content_type = 'application/x-www-form-urlencoded';for(var h inheaders ){if(headers.hasOwnProperty(h)){if(h.toLowerCase() === "content-type"){
content_type=headers[h];
}else{
xhr.setRequestHeader(h , headers[h]);
}
}
}
xhr.setRequestHeader('Content-type', content_type );
xhr.onreadystatechange= function(){if(xhr.readyState === 4){var err = (!xhr.status || (xhr.status < 200 || xhr.status >= 300) &&xhr.status!== 304);if( err === false){
resolve( xhr.responseText , xhr );
}else{
reject( err , xhr );
}//cb(err, xhr.responseText,xhr );
}
};
xhr.send(params);
});returnpromise;
};
})(window);