您好,登錄后才能下訂單哦!
var HOST = 'http://hummer.baidu.com'; var autoAjax = function(data){ if(!data || typeof data != 'object') return; var rnd = new Date().getTime(); if(!data.proxy) data.proxy = HOST + '/static/proxy.html?_='+rnd; var name = 'postIframe'; var proxyhost = /^((?:[^:\/?#]+):)?(\/\/([^/?#]*))?([^?#]*)(\?(?:[^#]*))?(?:#(.*))?$/.test(data.proxy); proxyhost = RegExp.$1 + RegExp.$2; var _host = /^((?:[^:\/?#]+):)?(\/\/([^/?#]*))?([^?#]*)(\?(?:[^#]*))?(?:#(.*))?$/.test(data.url); _host = RegExp.$1 + RegExp.$2; var _domain = 'http://' + location.host; var _back = function(ret){ try{ if(typeof ret === 'string'){ ret = ret.replace(/^[^{]+/img,''); ret = $.parseJSON(ret); } if(!!ret.source){ ret = ret.data; } if(typeof ret === 'string') ret = $.parseJSON(ret); }catch(_err){ ret = {success:1,info:'提交失敗'}; } data.callback(ret); }; if(_domain === _host && _host != ''){ var _data = {data: data.data}; var ajax = $.ajax({ type:'post', url: data.url, data: data.data }); ajax.always(_back); }else{ var oFrame = $('#'+name); if(!!oFrame.length){ oFrame.attr('src',data.proxy); }else{ oFrame = $('<iframe name="'+name+'" id="'+name+'" src="'+data.proxy+'" ></iframe>').appendTo(document.body); } var msg = { url: data.url, data: data.data }; if(typeof msg == 'object'){ msg = JSON.stringify(msg); } window.onmessage = _back; oFrame.unbind('load').load(function(){ this.contentWindow.postMessage(msg,HOST); }); } } var data = { url: "對應接口", callback: function(ret){ /*if(ret && ret.success == 0){ setCurrentDate(); createSearchList(ret); }else if(ret && ret.success == 2){ return poplayer({msg: ret.info,icon:'error',after:function(){ location.href = (ret.login_url || API.login); }}); }else{ return poplayer({msg: (ret ? ret.info : '獲取查詢列表失敗'),icon:'error'}); }*/ console.log(ret); } }; autoAjax(data);
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。