I want to receive array from php file by ajax , I tried Encode but didn't work , Any help?
php file :
$Data = array()
foreach($Query as $User){
//get Year variable
if($Year['Year'] == $YearPosted){
//get Name variable
$Data['Id'] = $Name['FirstName']." ".$Name['LastName'];
}
}
echo json_encode($Data);
js file :
$.ajax({
type: "post",
url: "Ajax/Users/GetUsers.php",
data: {
year: Year
},
success: function (data) {
alert(data.Id)
}
});
I want to receive from php File Something Like that
var User = [{
"1": "Name of UserId One"
}, {
"2": "Name of UserId One"
}]