Forum Moderators: open
I need to send id to script and return array..
I have try with $.get but don't work
now, I have try with JSON but nothin :'(
I have my first_page.php
Here I have try this
var mycontacts = new Array();
$.getJSON("log.php",{id: "5"}, function(ps){
for (var i = 0; i < ps.length; i++)
{
listacontattijs[i] = new Array('ps[0].idd', 'ps[1].email', 'ps[2].nome','ps[3].idg');
}
});
The file called set.php make a correct structure as
[{idc: 22, email: ex@amp.le, nome: Myname, idg: 3},{idc: 22, email: ex@amp.le, nome: Myname, idg: 3},{idc: 22, email: ex@amp.le, nome: Myname, idg: 3}]
Any help?
txx
I have try this:
var mycontacts = new Array();
$.getJSON("log.php",{id: 5}, function(ps){
for (var u = 0; u < ps.length; u++)
{
mycontacts[u] = new Array(ps[u].idd, ps[u].email, ps[u].nome, ps[u].idg);
console.log(mycontacts[u][1]);
}
}); console.log(mycontacts);
the first console (firebug) output is OK
the second, out of function and $.getJSON result nothing: [ ]
?
seems that var is empty after function.. but is global
Nb. var is defined before
help pls