jQuery 跨域访问的三种方式 No 'Access-Control-Allow-Origin' header is present on the reque
2016-10-07 18:10
489 查看
Js代码
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:
Js代码
$(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');
});
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:
Js代码
$(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');
});
相关文章推荐
- jQuery 跨域访问的三种方式 No 'Access-Control-Allow-Origin' header is present on the reque
- jQuery 跨域访问的三种方式 No 'Access-Control-Allow-Origin' header is present on the reque
- 本地Ajax跨域访问 No 'Access-Control-Allow-Origin' header is present on the requested resource.
- js跨域访问,no 'access-control-allow-origin' header is present on the requested resource
- 跨域 No 'Access-Control-Allow-Origin' header is present on the requested resource
- js跨域访问,No ‘Access-Control-Allow-Origin‘ header is present on
- 调用其他服务器的api时,暂时处理跨域问题的方法——No 'Access-Control-Allow-Origin' header is present on the requested resour
- 跨域问题:“No 'Access-Control-Allow-Origin' header is present on the requested resource”
- jquery ajax No 'Access-Control-Allow-Origin' header is present on the requested resource
- JS跨域:No 'Access-Control-Allow-Origin' header is present on the requested resource
- jquery跨域访问,no 'access-control-allow-origin' header is present on the requested resource
- 解决 ajax跨域 No 'Access-Control-Allow-Origin' header is present on the requested resource.
- ajax跨域请求:No 'Access-Control-Allow-Origin' header is present on the requested resource
- 跨域问题:No 'Access-Control-Allow-Origin' header is present on the requested resource.
- No 'Access-Control-Allow-Origin' header is present on the requested resource
- “No 'Access-Control-Allow-Origin' header is present on the requested resource”
- No 'Access-Control-Allow-Origin' header is present on the requested resource
- js跨域访问,No ‘Access-Control-Allow-Origin‘ header is present on
- “No 'Access-Control-Allow-Origin' header is present on the requested resource”
- No 'Access-Control-Allow-Origin' header is present on the requested resource.'Ajax跨域访问解决方案