I'm trying to access a the apex Map named "resultsMap" with javascript, I would like to get contact last name using contact id.
public class AccessMapJS {
public Map<ID, Contact> resultsMap{get;set;}
public String JsonMap{get;set;}
public AccessMapJS(){
resultsMap = new Map<ID, Contact>([SELECT Id, LastName FROM Contact limit 3]);
JsonMap=JSON.serialize(resultsMap);
}
}
VF page:
<apex:page controller="AccessMapJS" >
<script>
// Access here resultsMap: get contact last name using contact id
</script>
{!resultsMap}
</apex:page>
Do you know hoe to accomplish that ?
Thanks in advantage for any advice.
Best Answer
Your controller is fine.
You can get it in via javascript if thats your preference: