python&JSONP(Jquery篇),,采用Jquery发送
python&JSONP(Jquery篇),,采用Jquery发送
采用Jquery发送跨域请求:
1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8"> 5 <title>Title</title> 6 </head> 7 <body> 8 <h1>后台获取结果</h1> 9 {{ result }}10 <h1>JS直接获取结果</h1>11 <input type="button" value="XHR数据" onclick="xhrContent();">12 <input type="button" value="JSONP数据" onclick="getContent();">13 <input type="button" value="Jquery数据" onclick="JqueryContent();">14 <div id="container"></div>15 <script src="/static/jquery.min.js"></script>16 <script>17 function JqueryContent(){18 $.ajax({19 url:"http://www.jxntv.cn/data/jmd-jxtv2.html?_=14543768704003",20 type:"POST",21 dataType:"jsonp", // 请求格式22 jsonp:"callback", // 参数名23 jsonpCallback:"list" // 默认回调函数24 })25 }26 function list(arg){27 console.log(arg)28 }29 function xhrContent(){30 var xhr = new XMLHttpRequest();31 xhr.open(‘GET‘,‘http://www.jxntv.cn/data/jmd-jxtv2.html?callback=list&_=14543768704003‘);32 xhr.onreadystatechange = function(){33 console.log(xhr.responseText);34 }35 xhr.send();36 }37 function getContent(){38 var tag = document.createElement(‘script‘);39 tag.src= ‘http://www.jxntv.cn/data/jmd-jxtv2.html?callback=list&_=14543768704003‘;40 document.head.appendChild(tag); // 表示创建一个标签,并且放到head中41 document.head.removeChild(tag);42 }43 function list(arg){44 console.log(arg);45 }46 </script>47 </body>48 </html>
python&JSONP(Jquery篇)
相关内容
- Xcode搭建python开发环境,,1.找到电脑上安装P
- Python-requests的使用 - SSL证书验证,,一、SSL问题1、在
- python下使用ElasticSearch,,一 什么是 Elas
- python 安装matplotlib,,Ubuntu安装Ma
- Python_字符串格式化,, 1 #冒泡排序 2
- python实现累乘multi函数(函数参数不限),,def multi(
- Python 第一课笔记,,1、Hello Wo
- python:others,,#格式化print
- python中a,b=b,a原理,,python中 a
- python --help查询python相关命令,,C:\Users\l
评论关闭