我需要从这个url https://api.intelligentsolution.com.ve/inmobiliar/api/Propiedades/tasacion中读取json数据
但我总是得到一个未定义的值
即使我可以通过开发人员工具在响应中看到json数据。由于某种原因,我不能打印或使用它,因为我想
function print(data) {
console.log(data);
};
$.ajax({
url: 'https://api.intelligentsolution.com.ve/inmobiliar/api/Propiedades/tasacion',
dataType: 'jsonp',
jsonpCallback: print,
jsonp: 'callback',
});
发布于 2019-04-17 04:03:21
由于您坚持只从客户端发出请求,因此您可以使用第三方API来支持对任何地方的跨域请求。
代码如下:
function print(data) {
console.log(data);
};
$.ajax({
// using third party API https://cors-anywhere.herokuapp.com/
url: 'https://cors-anywhere.herokuapp.com/https://api.intelligentsolution.com.ve/inmobiliar/api/Propiedades/tasacion',
dataType: 'json',
success: print,
error: function() {
console.log('Unable to complete the request');
}
});
https://stackoverflow.com/questions/55712583
复制相似问题