如果从在线数据库服务器获取json数据,则无法在页面上显示json数据,但它可以在本地服务器数据库

时间:2015-12-01 09:20:02

标签: javascript json server ionic

这是从在线数据库服务器获取json数据的代码..

.factory('temanService', function($http) {
    var baseUrl = 'http://dwellingtime.net23.net/DwellingTime/';
    return {
        getAll: function() {
            return $http.get(baseUrl+'select.php');
        },
        getId: function (temanId){
            return $http.get(baseUrl+'select_id.php?id='+temanId); 
        },
        create: function (datateman){
            return $http.post(baseUrl+'insert.php',datateman,{
                headers: {
                    'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8;'
                }
            });
        },
        update: function (datateman){
            return $http.post(baseUrl+'update.php',datateman,{
                headers: {
                    'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8;'
                }
            });
        },
        delete: function  (id){
            return $http.get(baseUrl+'delete.php?id='+id);
        }
    };

});

但当我将baseUrl设置为“http://localhost/DwellingTime/”时,它可以工作(json数据显示在页面上)

这是baseUrl设置为../localhost/DwellingTime/时显示的图片 localhost_db

这里是显示json数据的代码

 <div class="bar bar-header">
    <button class="button button-icon icon ion-navicon"></button>
    <div class="h1 title">Data Teman</div>
    <button class="button button-clear button-positive">LogOut</button>
  </div>

<ion-view>
    <ion-content padding="false" class="has-header">
        <ion-refresher
            pulling-text="Pull to refresh..."
            on-refresh="showData()">
          </ion-refresher>
        <ion-list show-Delete = "data.showDelete" show-Reorder = "data.showReorder">
            <ion-item class="item-avatar item-icon-right" ng-repeat="datateman in datatemans" type="item-text-wrap" href="#/tab/teman/{{datateman.username}}">
                <img ng-src="{{datateman.username}}">
                <i class="icon ion-ios7-arrow-right"></i>
                <h2>{{datateman.username}}
                    <br> 
                    <font size="2" color="gray" >Spesialis : {{datateman.password}}</font>
                </h2>
                <ion-delete-button class="ion-minus-circled" ng-click="delete(datateman);"></ion-delete-button>
            </ion-item>
        </ion-list>
    </ion-content>
</ion-view>

0 个答案:

没有答案