Angular & Ionic, $http not working in real device Android

时间:2022-06-11 19:47:19

I am working on ionic application and using $http for get the data from web service. I have tested and its working on browser perfectly but i don't know why its not working on my android mobile, it just keep processing and after 3 to 5 mins it shows:

我正在研究离子应用程序并使用$ http从Web服务获取数据。我已经测试了它在浏览器上的完美工作,但我不知道为什么它不能在我的Android手机上工作,它只是继续处理,并在3到5分钟后显示:

ionic.bundle.js:25000 POST http://xyz-domain.com/api/ net::ERR_CONNECTION_TIMED_OUT

Even i have installed cordova-plugin-whitelist plugin but still getting same.

即使我已经安装了cordova-plugin-whitelist插件,但仍然相同。

My Code:

我的代码:

var ApiURL = 'http://xyz-domain.com/api/';
$http({

    url: ApiURL,
    method: 'POST',
    data: 'action=activate&app_secret=123456',
    headers: {
        'Content-Type': 'application/x-www-form-urlencoded'
    }
}).then(function(res){
    alert(res);
});

Can any one please tell me how i can solve this issue ?

任何人都可以告诉我如何解决这个问题?

Thanks

谢谢

1 个解决方案

#1


1  

This might be the case that your white list plugin and android platform version are not compatible.Happened to me also.Updating the platform and the plugin resolved the issue.Also can you alert the data, status, headers, config that are returned by the service.

这可能是你的白名单插件和android平台版本不兼容的情况。也发生在我身上。更新平台和插件解决了这个问题。你也可以提醒由数据,状态,标题,配置返回的服务。

#1


1  

This might be the case that your white list plugin and android platform version are not compatible.Happened to me also.Updating the platform and the plugin resolved the issue.Also can you alert the data, status, headers, config that are returned by the service.

这可能是你的白名单插件和android平台版本不兼容的情况。也发生在我身上。更新平台和插件解决了这个问题。你也可以提醒由数据,状态,标题,配置返回的服务。