很久没有写过原生的了,一时间竟然忘了,所以记录下来
jsonp的原理就是script的src属性;
上代码首先建立一个index.html
<script type="text/javascript"> function indexLong(result) { console.log(result); } </script><script type="text/javascript" src="index.json?callback=indexLong"></script>
这里面有个需要注意的地方就是回调函数要写在本身callback之前
然后同级建立一个index.json
indexLong({"a":"lllll"})这样就好了