本地与托管的宁静服务。 angular和codeigniter restserver

时间:2015-01-07 03:44:01

标签: angularjs ionic-framework restangular codeigniter-restserver

之前,我有一个关于将数据发布到php中的Restful服务的问题:

ionic restful authentication to POST and get data from php

现在我有一个奇怪的错误。它只发生在我托管的api上。但当我将网址更改为我的本地时,

http://localhost/my-serv/api/myrest/method

它正在工作,我收到显示输入数据的警报。但是当我把它改成我的托管网址时

http://my-domain.com/my-serv/api/myrest/method它什么也没做。

这是我应用中的所有内容:

var tapp = angular.module('tapp', ['ionic', 'ngCordova', 'restangular']);
var baseURL = 'http://localhost/my-serv/api/myrest/';
tapp.config(function($stateProvider, $urlRouterProvider, RestangularProvider){
$stateProvider
.state('tapp.test', {
    url: '/tester',
    views: {
       'tappMenu':{
    templateUrl: 'template/tester.html',
     }
   }
});
RestangularProvider.setBaseUrl(baseURL);
}

控制器

tapp.controller('tCtrl', function($scope, $http, Restangular){
   var posted = Restangular.all('posted');
   $scope.inData = {};
   $scope.tester = function(){
     var posting = { name: $scope.inData.text };
     posted.post(posting).then(function(re){
     alert(re.values);
     }, function(o){
       alert(o);
     });
   };
});

html模板

<ion-view title="TEST">
<ion-content ng-controller="tCtrl">
    <form ng-submit="tester()">
    <div class="list">
        <label class="item item-input">
            <input type="text" name="testing" ng-model="inData.text" placeholder="First Name">
        </label>
    </div>
    <button type="submit" class="button button-block button-royal">Submit</button>
    </form>
</ion-content>

php codeigniter rest server

<?php defined('BASEPATH') OR exit('No direct script access allowed');

require APPPATH.'/libraries/REST_Controller.php';

class Myrest extends REST_Controller
{
    public function __construct()
   {
      parent::__construct();
        //$this->methods['user_get']['limit'] = 500; //500 requests per hour per user/key
   }
   public function posted_post()
   {
     $ok = $this->post('name');

     $arr = array('values'=>$ok);
     $this->response($arr, 200);
   }
}

0 个答案:

没有答案