function nativeAjax(opt) { opt = opt || {}; opt.method = opt.method.toUpperCase() || 'POST'; opt.url = opt.url || ''; opt.async = opt.async || true; opt.data = opt.data || null; opt.success = opt.success || function () {}; opt.failed = opt.failed || function () {}; var xhr = null; if (XMLHttpRequest) { xhr = new XMLHttpRequest(); } else { xhr = new ActiveXObject('Microsoft.XMLHTTP'); } var params = []; for (var key in opt.data) { params.push(key + '=' + opt.data[key]); } var postData = params.join('&'); if (opt.method.toUpperCase() === 'POST') { xhr.open(opt.method, opt.url, opt.async); xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;charset=utf-8'); xhr.send(postData); } else if (opt.method.toUpperCase() === 'GET') { xhr.open(opt.method, opt.url + '?' + postData, opt.async); xhr.send(null); } xhr.onreadystatechange = function () { if (xhr.readyState == 4 ) { if(xhr.status == 200){ opt.success(xhr.responseText); }else{ opt.failed(xhr.status); } } }; } function getLocal(){ return window.navData===undefined?parent.location:location; } function checkPower(name,success,failed){ var _user=sessionStorage.getItem('user'); var _id=sessionStorage.getItem('id'); var _name=sessionStorage.getItem('name'); if(!(_user&&_id&&_name)){ getLocal().href='/'; } typeof success!=='function'&&(success=function(){}); typeof failed!=='function'&&(failed=function(){getLocal().href='/';}); nativeAjax({ method:'get', url:'/ems/monitorBusiness/isPageAndReportAuthority', async:false, data:{ type:0, content:name }, success:function(res){ success(res); }, failed:function(code){ failed(code); }, }); }