Problem:
XMLHttpRequest cannot load http://v.xxx.com. No ' Access-control-allow-origin ' header is present on the requested resource. Origin ' http://localhost:63342 ' is therefore not allowed access. Test.html:1
Solution:
$ (function ($) {var url = ' Http://v.juhe.cn/weather/index '; $.ajax (URL, {data: {' cityname ': ' Xiangyang ', ' dtype ': ' Jsonp ', ' key ': ' xxxx ', ' _ ': New Date (). GetTime ()}, DataType: ' Jsonp ', Crossdomain:true, success:functi On (data) {if (data && Data.resultcode = = ' + ') {Console.log (data.result.today); } } }); var url2 = ' http://v.juhe.cn/weather/index?callback=? '; $.getjson (url2, {' CityName ': ' Beijing ', ' dtype ': ' Jsonp ', ' key ': ' xxxx ', ' _ ': New Date (). g Ettime ()}, function (data) {if (data && Data.resultcode = = ' + ') {Console.log (data.resu Lt.today); } }); var url3 = ' http://v.juhe.cn/weather/index?callback=? '; $.get (Url3, {' CityName ': ' Macau ', ' dtype ': ' Jsonp ', ' key ': ' xxxx ', ' _ ': New Date(). GetTime ()}, function (data) {if (data && Data.resultcode = = ' + ') {console.log (data. Result.today); }}, ' json '); });
Three ways to access jQuery across domains No ' Access-control-allow-origin ' header is present on the Reque