python --jsonp
Posted 富0代
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python --jsonp相关的知识,希望对你有一定的参考价值。
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>about_jsonp2 xyz</title> </head> <body> <button id="b1">点我</button> <button id="b2">点我cba</button> <form action="https://www.sogou.com/web" method="get"> <input type="text" name="query"> <input type="submit" value="搜"> </form> <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.js"></script> <!-- <script> function alex(res) { console.log(\'我是大帅逼!\'); console.log(res); } function bhj(res) { console.log(res); $.each(res, function (k, v) { console.log(k, v) }) } </script> --> $(\'#b2\').click(function () { $.ajax({ url: \'http://www.jxntv.cn/data/jmd-jxtv2.html?callback=list&_=1454376870403\', dataType: \'jsonp\', jsonp: \'callback\', jsonpCallback: \'list\', success: function (data) { var weekList = data.data; var $tvListEle = $(".tv-list"); $.each(weekList, function (k, v) { var s1 = "<p>" + v.week + "列表</p>"; $tvListEle.append(s1); $.each(v.list, function (k2, v2) { var s2 = "<p><a href=\'" + v2.link + "\'>" + v2.name + "</a></p>"; $tvListEle.append(s2) }); $tvListEle.append("<hr>"); }) } }) }) <!--7 <script> $("#b1").click(function () { $.ajax({ url: "http://127.0.0.1:8010/abc/", dataType: "jsonp", // 指定此次请求是jsonp形式 success:function (res) { console.log(res); } }) }) </script> --> <!-- 06 <script> function lyl(res){ console.log("我是凌云龙!"); console.log(res); } $("#b1").click(function () { $.ajax({ url: "http://127.0.0.1:8010/abc/", dataType: "jsonp", // 指定此次请求是jsonp形式 jsonp: "callback", // 回调函数的URL参数 jsonpCallback: "lyl" // 回调函数的函数名 }) }) </script> --> <!-- 05 <script> $("#b1").click(function () { $.getJSON("http://127.0.0.1:8010/abc/?callback=?", function (res) { console.log(res); }) }) </script> --> <!-- 04 <script> function addScriptTag(url, func){ var scriptEle = document.createElement("script"); $(scriptEle).attr("src", url+"?callback=" + func); $("body").append(scriptEle); $(scriptEle).remove(); } $("#b1").click(function () { addScriptTag("http://127.0.0.1:8010/abc/", "alex") }); $("#b2").click(function () { addScriptTag("http://127.0.0.1:8010/cba/", "bhj") }) </script> --> <!-- 03 <script> $("#b1").click(function () { var scriptEle = document.createElement("script"); $(scriptEle).attr("src", "http://127.0.0.1:8010/abc/"); $("body").append(scriptEle); $(scriptEle).remove(); }) </script> --> <!-- 02 <script src="http://127.0.0.1:8010/abc/"></script> --> <!-- 01 <script> $("#b1").click(function () { $.ajax({ url: "http://127.0.0.1:8010/abc/", type: "get", success:function (res) { console.log(res); } }) }); </script> --> </body> </html>
https://www.cnblogs.com/liwenzhou/p/9513648.html
以上是关于python --jsonp的主要内容,如果未能解决你的问题,请参考以下文章