Search Posts

Category: codeigniter

not able to alert json data in ajax success call

I am not able to alert the first name of the user $scope.Edit=function(id){ $ “<?php echo BASE_URL;?>Registration/Edit”, {id :id} ).then(function(response){ var myJSON = JSON.stringify(; alert(myJSON); //alert(response.first_name); $ = response.first_name; name(); //alert(; }); } After This function in angular js: In json response i am getting: {“id”:”4″,”first_name”:”Rupal”,”last_name”:”Pant”} my php function which return the json value is: public function Edit(){ $data = json_decode(file_get_contents(“php://input”)); $id=$data->id; $query = “select * from tbl_user where id='”.$id.”‘”; $check = $this->db->query($query); $result = […]

How to update angular data without refreshing the page?

I have some data in a database table that I used angular to show it. And I use the following script which is in the footer to do that: <script !src=””> var app = angular.module(‘enterprise’, []); app.controller(‘entercontroller’, function($scope, $http){ console.log(‘success’); $‘http://localhost/clinic/Groups_/load_data’) .then(function(mydata){ console.log(mydata); $scope.datas =; }); $scope.loadData=function(){ $‘http://localhost/clinic/Groups_/load_data’) .then(function(mydata){ $scope.datas.push(; }); } }); And my load_data() function in my controller like: public function load_data(){ $data[“groups”] = $this->Groups->fetch_groups(); return $this->output ->set_status_header(200) ->set_content_type(‘application/json’, ‘utf-8’) ->set_output(json_encode($data[“groups”], JSON_PRETTY_PRINT […]

AngularJS – POST JSON Array To MySQL Database – PHP

Okay so I am working on a Codeigniter 3.0 application and attempting to post an array of JSON data to the database. But I am not getting an logs regarding the issue and cant seem to find out what I am doing wrong. Any help would be greatly appreciated. Right now here is the following Angular Array: $scope.packageDetails = [ {ID: 1898, Number: 909, Name: “test”, category: “cat”}, {ID: 1899, Number: 919, Name: “test 2”, […]

How to fetch a value from a database in a <p> tag and to post them into database with the same id

I am new to angularjs and I want to make an application just like a Google keeps notes. I succeed in fetching the data inside the <p> tag in the list format. My condition is whenever I make any changes in the <p> tag, it is in the database. I tried to do this with ngKeyup() but I did not succeed so I removed ngKeyup(). How can I do this with the ajax jquery or […]

CodeIgniter 3 Implement Promise

My CI app makes API call to third party Rest API server which will be consumed by front end. At first, front end app will hit my CI app and which in turn will hit third party LogInAPI(session valid for 15 mins), and after login we need to hit subsequent API calls by passing the key(response of loginApi) in header. So basically I need to hit loginAPI for every 15 minutes. I am trying angular […]

codeigniter angular js fetch data

I have “Posts” controller and “loaddata” function which : public function loaddata(){ $q = $this->db->get(‘posts’)->result(); $m = json_encode($q); $this->load->view(‘ang’, $m); } and my “ang” file in view: <div ng-app=”myApp” ng-controller=”myctl”> <ul ng-repeat = ‘x in users’> <li>{{ }}</li> </ul> </div> <script> var app = angular.module(‘myapp’, []); app.controller(‘myctl’, function ($scope, $http) { $http.get(<?= site_url(‘posts/loaddata’) ?>).then(function (mydata) { $scope.users =; }); }); </script> but what I get is: {{}} please help and guide the solution. […]