$ http.post () returns status code 0 on device, but works fine in Chrome - Cordova / Ionic platform

I am making a call to $ http.post () to grab content from my site.

I stated:

<access origin="*" />

      

in my config.xml file. Also, the PHP file I am calling has

header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept");

      

My function code looks like this:

function loadFeed() {

            $scope.show();

            $http.defaults.useXDomain = true;
            $http.defaults.headers.post['Content-Type'] = 'application/json;charset=utf-8';

            var postUrl = 'https://wefemales.com/android/getFeed.php';
            $scope.postUrl = $sce.trustAsResourceUrl(postUrl);
            $http.post(postUrl)
                .success(function (result) {
                    $scope.hide();
                    $scope.items = eval(result.data);
                    $scope.$broadcast('scroll.refreshComplete');
                })
                .error(function(status) {
                    alert(status);
                    $scope.hide();

                });
            }

            $scope.doRefresh = loadFeed;

            loadFeed();

        });

      

Now when I test a project in chrome using ionic service everything works fine, but when I test it with Galaxy Tab 3 it returns status code: 0

I spent about two days looking for a solution, but still nothing.

One more thing, my CordovaApp-debug.apk works great, but the problem occurs when I sign the app using jarsigner and zip aligns it.

Please, if someone can help me with this, it would be great.

I am new to ionic / cordova but a quick learner.

+3


source to share





All Articles