0

I am using Ionic and making http request like this:

$http.get('//GLOBAL.IP/?username=' + username + '&content_type=json')
            .then(function (result) {
                $scope.days = [];

                alert(JSON.stringify(result));

                for (first in result.data.weeks) break;

                var currentWeek = result.data.weeks[first];
                var time = currentWeek.overall.as_time;

                $scope.week = currentWeek;
                for (day in currentWeek.days.sort().reverse()) {
                    if (day < 2) {
                        continue;
                    }
                    var currentDay = currentWeek.days[day];
                    $scope.days.push(currentDay);

                    if (currentDay.present) {
                        console.log(parseInt(currentDay.work_time_balance) + parseInt(currentWeek.overall.seconds));
                    }

                }
            }, function (result) {

                alert(JSON.stringify(result));

                $ionicPopup.alert({
                    title: 'Error',
                    template: 'Connection failed, try again later!'
                });
            })
            .finally(function () {
                // Stop the ion-refresher from spinning
                $scope.$broadcast('scroll.refreshComplete');
            });

While I am opening app in browser with command ionic serve, everything seems working okay, I've already fixed CORS and other stuff. But when In mobile app, I am getting this (sorry for not providing plaintext)

enter image description here

UPDATE

        $http.get('//GLOBAL.IP/?username=' + username + '&content_type=json')
            .then(function (result) {
                alert('Good');
            }, function (result) {
                alert('Bad');
            })

This code returns me GOOD, but result.data is still with script tags.

2 Answers 2

1

When you are testing this app in working mode what is localhost, Its a local server running on same machine, right.

When you install or run app in your mobile device where it is pointing to? Do you know that, If code is okay then replacing localhost with IP of your machine should resolve this issue.

Sign up to request clarification or add additional context in comments.

2 Comments

Hey, yes, i ll modify my question, actually ip is "global" and http request tells me what it is successfull, just "data" is very strange.
Sorry, but your answer isnt fixing the problem, so it's not really an "answer"
0

Many script tags with addRow in ionic http request response, was because of // in the beginning of uri, protocol was selecting successfully in browser, but not in compiled app.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.