I'm creating a kind of API system like any social network :D Basically, i created a php page that call with $getJSON method:
This is getuser.php
<?
include 'config.php'; connect();
$get = trim(strip_tags($_GET['id']));
$sql = "SELECT username,id,avatar FROM utenti WHERE id = $get ";
$result = mysql_query($sql);
while ($row = mysql_fetch_array($result,MYSQL_ASSOC))
{
$row_set[] = $row;
}
echo json_encode($row_set);
?>
(example id=2)
[{"username":"Firefoxer","id":"2","avatar":"account\/firefoxer\/pic.jpg"}]
And .js function
$.getJSON('getuser.php', {
id: user
}, function (data) {
callback = data.avatar
});
alert(callback);
Question is... why it returns undefined object every time ? Code seems right, any ideas ?