function Jsonp(url){ var url=url.indexOf('?')>-1?url+"&callback=callback":url+"?callback=callback"; return new Promise(function(resolve,reject){ var script=document.createElement('script'); script.src=url document.head.appendChild(script); window.callback=function(param){ resolve(param) } }) } //后台返回数据示例:callback({'name':'liuhao'}) Jsonp("http://192.168.1.100:2015/").then(function(res){ console.log(res)//{'name':'liuhao'} })