jsonp原理,定义的回调是怎么定义的、局部还是全局

<script>标签的src属性并不被同源策略所约束,可以获取任意服务器上的脚本并执行

服务器返回全局的函数的执行

var script=document.createElement(script)

script.type=text/javascript

script.src=http://domain2.com/index.html?userName=admin&callback=handlecallback

function handlecallback(res){

  console.log(res)

}

猜你喜欢

转载自www.cnblogs.com/zhuMother/p/12199968.html
今日推荐