jsonP (JSON with Padding) 跨域
JSONP 是一种非正式传输协议,该协议的一个要点就是允许用户传递一个 callback(或者一开始就定义一个回调方法)参数给服务端,然后服务端返回数据时会将这个 callback 参数作为函数名来包裹住 JSON 数据,这样客户端就可以随意定制自己的函数来自动处理返回数据了。
例如:
html
<script>
function say(data) {
console.log(data)
}
</script>
<script src="./other.js?cb=say"></script>js
//other.js 另一个域下
say('hello1')