原生跨域请求数据

 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>

跨域请求数据HTML页面

 jQuery跨域请求数据

 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>

jQuery跨域请求数据

 

版权声明:本文为sun-10387834原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/sun-10387834/p/12495230.html