Ionic http get request (with Angular) returns html data

I am making http request like this:

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


                for (first in break;

                var currentWeek =[first];
                var time = currentWeek.overall.as_time;

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

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

            }, function (result) {


                    title: 'Error',
                    template: 'Connection failed, try again later!'
            .finally(function () {
                // Stop the ion-refresher from spinning

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


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

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

so like … what do you get when you open the url in the browser

//IP/?username=' + username + '&content_type=json

Seems like you’re using a protocol relative url (//) to your backend. This will work in the browser using ionic serve, but not in a mobile app.
Replace it with http:// (or https:// ) and check the results.
Personally I would replace the alert statements with console.log statements. Alerts are blocking, and console.log will allow you to log complete objects to the developer console. Easier for debugging.


Solved! Thank you very much!

so what did you do to solve it?

As @tomkuipers it was protocol problem because of //