面对跨域问题,在http状态为200时,在jsonp响应中获取error_code 1000 [英] Facing cross-domain issue, getting error_code 1000 in jsonp response while http status is 200
问题描述
有REST API,我试图从中获取响应。
问题是如果我使用JSONP克服跨域问题然后我得到error_code:1000在控制台中。
这是我在控制台中得到的响应:
Object {header:Object,body:Object}
body:Object
error_code:1000
__proto __:Object
header:Object
__proto __:对象
这是我的AJAX通话看起来像
Hi,
There is REST API, from which I am trying to fetch response.
Issue is if I use JSONP to overcome cross-domain issue then I get error_code:1000 in console.
This is the response I get in console:
Object {header: Object, body: Object}
body:Object
error_code:1000
__proto__:Object
header:Object
__proto__:Object
This is my AJAX call looks like
$.ajax({
type: 'GET',
url: 'for security reason I cannot display API URL',
dataType: 'jsonp',
data: {
authtoken: AppFramework.constants.AUTHTOKEN
},
success: function(result) {
console.log(result) ;
}
});
};
这是白名单问题吗?我无法辨认。请建议。
我尝试了什么:
当我使用时数据类型为JSON,它给出了跨域错误。
我得到以下错误。
XMLHttpRequest无法加载https://www.site24x7.com/api/reports/availability_summary?period= 3及的authToken = 2f8671565a3cbb9e44b858160355ad7c。请求的资源上不存在Access-Control-Allow-Origin标头。因此,不允许来源http://127.0.0.1:59185。
Is this a whitelisting issue? I am unable to identify. Please suggest.
What I have tried:
When I use data type as JSON, it gives cross domain error.
I get below error.
XMLHttpRequest cannot load https://www.site24x7.com/api/reports/availability_summary?period=3&authtoken=2f8671565a3cbb9e44b858160355ad7c. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://127.0.0.1:59185' is therefore not allowed access.
推荐答案
.ajax({
type:' GET',
url:' 出于安全原因我无法显示API URL',
dataType:' jsonp',
data:{
authtoken:AppFramework.constants.AUTHTOKEN
},
成功:函数(结果){
console .log(result);
}
});
};
.ajax({ type: 'GET', url: 'for security reason I cannot display API URL', dataType: 'jsonp', data: { authtoken: AppFramework.constants.AUTHTOKEN }, success: function(result) { console.log(result) ; } }); };
这是白名单问题吗?我无法辨认。请建议。
我尝试了什么:
当我使用时数据类型为JSON,它给出了跨域错误。
我得到以下错误。
XMLHttpRequest无法加载https://www.site24x7.com/api/reports/availability_summary?period= 3及的authToken = 2f8671565a3cbb9e44b858160355ad7c。请求的资源上不存在Access-Control-Allow-Origin标头。因此,不允许访问http://127.0.0.1:59185。
Is this a whitelisting issue? I am unable to identify. Please suggest.
What I have tried:
When I use data type as JSON, it gives cross domain error.
I get below error.
XMLHttpRequest cannot load https://www.site24x7.com/api/reports/availability_summary?period=3&authtoken=2f8671565a3cbb9e44b858160355ad7c. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://127.0.0.1:59185' is therefore not allowed access.
这篇关于面对跨域问题,在http状态为200时,在jsonp响应中获取error_code 1000的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!