Data Convertion.
- To String: String.valueOf(data);
- To Integer: Integer.valueOf(data);
Stringified(Serialized) JSON to Apex Data.
private static void doSomething(String JSONString) {
Map<String, Object> myJSON = (Map<String, Object>) JSON.deserializeUntyped(JSONString);
Integer something = myJSON.get('key');
}
Execute Apex Class from Browser Client.
Apex Class:
Global with sharing class SomeClass {
// Dummy constructer
public SomeClass() {}
// Important, without RemoteAction, it wont work
@RemoteAction
public static String someFunction() {
return 'success';
}
}
Browser Client Side(JavaScript):
<apex:page controller="SomeClass">
<script>
SomeClass.someFunction(function(result, event) {
console.log(result); // outputs 'success';
});
</script>
</apex:page>
To be continue...?
No comments:
Post a Comment