|
沙发

楼主 |
发表于 2020-8-19 23:51:55
|
只看该作者
jsonp本地代码
- <script>
- $(function(){
- getData();
- setInterval(function(){
- var head = document.head || $('head')[0];
- var script = $(head).find('script')[0];
- if (script){
- var src = script.src || '';
- var idx = src.indexOf('callback=');
- if(idx != -1){
- var idx2 = src.indexOf('&');
- if (idx2 == -1){idx2 = src.length;}
- var jsonCallback = src.substring(idx + 9, idx2);
- delete window[jsonCallback];
- if (script.parentNode){
- script.parentNode.removeChild(script);
- }
- }
- }
- getData();
- }, 1000);
- });
- function getData(){
- jQuery.ajax({
- //src="http://127.0.0.1:808/hello1.html?callback=zz&_=1597846439408"
- //src="http://127.0.0.1:808/hello1.html?callback=jQuery17206514656749972916_1597846503900&_=1597846534352
- url:"http://127.0.0.1:808/hello1.html?BB=17",
- type:"GET",
- dataType:"jsonp",
- //jsonp: "callback",
- //jsonpCallback:"zz",
- success:function(result){
- alert(result);
- } ,
- error:function(xOptions, textStatus){console.log(textStatus);}
- })
- };
- </script>
复制代码 |
|