Jsonp
原生跨域请求数据
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8"> 5 <title>Title</title> 6 </head> 7 <body> 8 <div id="content"></div> 9 <button onclick="jsonp()">提交</button> 10 11 <script src="/static/jquery-1.11.0.js"></script> 12 <script> 13 function jsonp() { 14 var tag=document.createElement("script"); 15 tag.src="http://www.jxntv.cn/data/jmd-jxtv2.html?callback=list&_=1454376870403"; 16 document.head.appendChild(tag); 17 document.head.removeChild(tag); 18 } 19 20 function list(arg) { 21 console.log(arg); 22 } 23 </script> 24 </body> 25 </html>
jQuery跨域请求数据
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8"> 5 <title>Title</title> 6 </head> 7 <body> 8 <div id="content"></div> 9 <button onclick="jsonp()">提交</button> 10 <button onclick="ajax_jsonp()">ajax提交</button> 11 12 <script src="/static/jquery-1.11.0.js"></script> 13 <script> 14 function ajax_jsonp() { 15 $.ajax({ 16 url:"http://www.jxntv.cn/data/jmd-jxtv2.html?callback=list&_=1454376870403", 17 type:"GET", 18 dataType:"jsonp" 19 }) 20 } 21 22 function list(arg) { 23 console.log(arg); 24 } 25 26 </script> 27 </body> 28 </html>