javascript - JS, Angular, AJAX : how to mix those three? -


i use ajax function import json data php webpage, , then, use in angular js controller. problem is, nothing working.

here code :

(function(){   var xmlhttp = new xmlhttprequest();   var url = "ajax/get_pal.php?type=populars&page=";   xmlhttp.onreadystatechange=function() {     if (xmlhttp.readystate == 4 && xmlhttp.status == 200) {       pal = json.parse(xmlhttp.responsetext);     }   }   xmlhttp.open("get", url, true);   xmlhttp.send();    var app = angular.module('palmod', []);   app.controller('palcontroller', function(){     this.prod = pal;   }); })(); 

i'm still beginner in angularjs, i'm totally lost here. i'm doing wrong ?

get_pal.php send : (with datas, of course)

[{"id":"1","name":"test","list":"[]","date_post":""}, ......] 

don't mix plain ajax angularjs. angularjs gives method make ajax calls. use $http make calls.

var app = angular.module('myapp', []); app.controller('customersctrl', function($scope, $http) {     $http.get("http://www.websitename.com/file.php")     .success(function(response) {$scope.names = response.records; }); }); 

Comments

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -