I want to create a dynamic page (that's why i'm using angular.js) according to datas from my localhost database. I'm connecting into my DB using a jQuery ajax call function :
var ajaxCall = function(request,datas,async,onSuccess){
$.ajax({
async: async,
url: 'data.php',
type: "POST",
data: {
request: request,
datas: datas
},
dataType:"json",
success:function(returns){
if(onSuccess != null)
onSuccess(returns);
}
});
};
This is my angular file, including the ajaxCall to get my values :
(function(){
var app = angular.module('user', [ ]);
app.controller('MemberController', function() {
var user= this;
user.members= [];
ajaxCall("getMember",null,false,function(result){
for(var number in result)
user.members.push(result[number]);
});
setTimeout(function(){
console.log(user.members)
}, 2500);
});
})();
From the ajax call, I receive a JSON (valid on JSONLint) but in my angular code, when I console.log(user.members)
(even with a TimeOut of several seconds), the value of the array is still []
and I can't use it on my html page.
Do you have any idea why ? Or how can I change my code to make it work ? Thank you !