Goal
Request Jiangxi Network Broadcast TV program
Url:http://www.jxntv.cn/data/jmd-jxtv2.html
Analysis
1. From the HTTP header information analysis, the server server does not return the response header access-control-allow-xxxx related information, so only use Jsonp mode
2. From the content of the return value analysis, the return value is always: List (response content), that is: Because the server writes the function name to list, the specified callback is invalid in this program.
Realize
Get_tv_list.html
<!DOCTYPE HTML><HTMLLang= "en"><Head> <MetaCharSet= "UTF-8"> <title>Request a list of the latest TV programs across domains</title></Head><Body><H1>Cross-Domain requests</H1><inputtype= "Submit"value= "Xmlsendrequest Get program"onclick= "xmlsendrequest ();"/><inputtype= "Submit"value= "jqsendrequest-Get program"onclick= "jqsendrequest ();"/><Scripttype= "Text/javascript"src= "Http://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></Script><Script> functionxmlsendrequest () {//Create a script tag varTag=Document.createelement ('Script'); //Specify SRCtag.src= "http://www.jxntv.cn/data/jmd-jxtv2.html"; //add to head tagdocument.head.appendChild (tag); //Delete a script tagdocument.head.removeChild (tag); } functionjqsendrequest () {$.ajax ({URL:"http://www.jxntv.cn/data/jmd-jxtv2.html", type:'GET', DataType:'Jsonp'}) }
functionList (ARG) {console.log (ARG); }</Script></Body></HTML>
Ajax-08 to get the latest TV show list instances across domains