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 Resource interpreted as Script but transferred with MIME type text/html:
$(function($){ var url = 'http://v.juhe.cn/weather/index'; $.ajax(url, { data: { 'cityname': '襄阳', 'dtype': 'jsonp', 'key': 'xxxx', '_': new Date().getTime() }, dataType: 'jsonp', crossDomain: true, success: function(data) { if(data && data.resultcode == '200'){ console.log(data.result.today); } } }); var url2 = 'http://v.juhe.cn/weather/index?callback=?'; $.getJSON(url2, { 'cityname': '北京', 'dtype': 'jsonp', 'key': 'xxxx', '_': new Date().getTime() }, function(data){ if(data && data.resultcode == '200'){ console.log(data.result.today); } }); var url3 = 'http://v.juhe.cn/weather/index?callback=?'; $.get(url3, { 'cityname': '澳门', 'dtype': 'jsonp', 'key': 'xxxx', '_': new Date().getTime() }, function(data){ if(data && data.resultcode == '200'){ console.log(data.result.today); } }, 'json'); });
相关推荐
ajax跨域访问是一个老问题了,解决方法很多,比较常用的是JSONP方法,JSONP方法是一种非官方方法,而且这种方法只支持GET方式,不如POST方式安全...因此,通过设置Access-Control-Allow-Origin来实现跨域访问比较简单。
header("Access-Control-Allow-Origin:*"); /*星号表示所有的域都可以接受,*/ header("Access-Control-Allow-Methods:GET,POST"); 3.jsonP 原理: ajax本身是不可以跨域的, 通过产生一个script标签来实
JQuery跨域访问解决方案 JQuery
ajax跨域访问是一个老问题了,解决方法很多,比较常用的是JSONP方法,JSONP方法是一种非官方方法,而且这种方法只支持GET方式,不如POST方式安全。 即使使用jQuery的jsonp方法,type设为POST,也会自动变为GET。 ...
这是一份非常有用的Jquery跨域访问实例,里面提供了3种方法,前台后台都有涉及,希望对你们会有所帮助
jquery.i18n.properties-min-1.0.9 主要用于国际化和读取properties文件
jquery-1.3.2-vsdoc.js jquery-1.8.3.min.js jquery-1.3.2.min.js jquery-1.4.1-vsdoc.js jquery-1.4.1.min.js jquery-1.4.2-vsdoc.js jquery-1.4.2.min.js jquery-1.4.3-vsdoc.js jquery-1.4.3.min.js ...
开发工具 jquery-1.11.3.min开发工具 jquery-1.11.3.min开发工具 jquery-1.11.3.min开发工具 jquery-1.11.3.min开发工具 jquery-1.11.3.min开发工具 jquery-1.11.3.min开发工具 jquery-1.11.3.min开发工具 jquery-...
Jquery跨域访问Web服务的demo源码
jquery-1.9.1 VS智能提示插件
jquery-1.10.2.min.js jquery-1.11.1.min.js jquery-1.11.3.min.js jquery-1.2.3.min.js jquery-1.3.2.min.js jquery-1.4.2.min.js jquery-1.4.4.min.js jquery-1.5.2.min.js jquery-1.6.4.min.js jquery-1.7.2.min....
jquery.i18n.properties-min-1.0.9.js前端国际化文件 jquery插件,实现国际化
jQuery省市区三级联动插件city-picker,省市区三级联动demo
jquery-easyui-1.2.2jquery-easyui-1.2.2jquery-easyui-1.2.2
JAVA调用外接设备(制卡机)---JQuery跨域,AJAX跨域问题
jquery显示当前时间(年-月-日 小时:分钟:秒 星期几) 实时动态的时间显示
jquery-ui-1.8.16jquery-ui-1.8.16jquery-ui-1.8.16jquery-ui-1.8.16jquery-ui-1.8.16jquery-ui-1.8.16jquery-ui-1.8.16jquery-ui-1.8.16jquery-ui-1.8.16jquery-ui-1.8.16jquery-ui-1.8.16jquery-ui-1.8.16jquery-...
jquery-1.4.2.js jquery-1.4.2.min.js jquery-1.4.2-vsdoc.js 中文版vsdoc jquery-1.4.2-vsdoc_en.js jquery.cookie.js
jquery-3.7.0.min.js(jQuery下载)jquery-3.7.0.min.js(jQuery下载)jquery-3.7.0.min.js(jQuery下载)jquery-3.7.0.min.js(jQuery下载)jquery-3.7.0.min.js(jQuery下载)jquery-3.7.0.min.js(jQuery下载)...
header('Access-Control-Allow-Origin:*');//允许所有来源访问 header('Access-Control-Allow-Method:POST,GET');//允许访问的方式 使用http-proxy-middleware 代理解决(项目使用vue-cli脚手架搭建) 打开config/...