【发布时间】:2016-05-02 16:43:27
【问题描述】:
在 Ionic 框架中,在控制器内部,我有以下非常简单的 Angular http get 调用:
$http({
method: 'GET',
timeout: '9999',
responseType: 'json',
url: 'see below'
}).then(function successCallback(response) {
console.log('WORKS');
alert(response.status);//200 OK
}, function errorCallback(response) {
console.log('ERROR');
alert(response.status);// always empty, why?
});
// works:
// http://maps.googleapis.com/maps/api/geocode/json?address=77379&sensor=true
// http://www.omdbapi.com/?t=lord
// fail:
// http://md5.jsontest.com/?text=1234
当您调用底部的 url 时,其中两个有效,其中两个失败。
为什么会这样?我试过了:
- 标头编码问题
- 标头 mime 类型(应用程序/json 和其他)
- 检查格式错误的 json / 空格
- 超时(设置为 9999 毫秒)
- 访问控制允许来源:*
我还能尝试什么?感谢您的帮助!
【问题讨论】:
标签: angularjs json http ionic-framework