previously, i have a question here about posting data to the Restful service in php:
ionic restful authentication to POST and get data from php
now i have a weird bug. it is only occur on my hosted api. but when i change the url to my local,
http://localhost/my-serv/api/myrest/method
it is working, i get the alert showing my input data. but when i change it to my hosting url
http://my-domain.com/my-serv/api/myrest/method
it does nothing.
this is all the things on my app:
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);
}
controller
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 template
<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);
}
}