APEX JAVASCRIPT JSON Visual Force

Json in Apex class and Visualforce

Serializing JSON from Apex  Apex Class: public with sharing class jsonAccount { public string AccountNameList {get;set;}  public jsonAccount() {    list accList = [Select Id,Name From Account];     System.debug(JSON.serialize(accList));    AccountNameList = JSON.serialize(accList); } } Output:USER_DEBUG [2]|DEBUG|[{“attributes”:{“type”:”Account”,”url”:”/services/data/v24.0/sobjects/Account/001U0000002LdBXIA0″},”Id”:”001U0000002LdBXIA0″,”Name”:”GenePoint”},{“attributes”:{“type”:”Account”,”url”:”/services/data/v24.0/sobjects/Account/001U0000002LdBYIA0″},”Id”:”001U0000002LdBYIA0″,”Name”:”United Oil & Gas, UK”},{“attributes”:{“type”:”Account”,”url”:”/services/data/v24.0/sobjects/Account/001U0000002LdBZIA0″},”Id”:”001U0000002LdBZIA0″,”Name”:”United Oil & Gas,…

Read More
APEX Web Service

HTTP Callout from Apex Class

public class simpleHTTPCallOut {public simpleHTTPCallOut(ApexPages.StandardController controller) { } String ErrorMessage; public void Login() {  ErrorMessage=”;  final string baseUrl = ‘https://login.salesforce.com/‘;  final string username = ‘test@test.com’;  final string password = ‘test@123’;  Http h = new Http();  HttpRequest req = new HttpRequest();…

Read More
JAVASCRIPT

Get URL Parameters (QueryStrings) using Javascript

function getQueryStringValue(key, default_){  if (default_==null) default_=””;  key = key.replace(/[\[]/,”\\\[“).replace(/[\]]/,”\\\]”);  var regex = new RegExp(“[\\?&]”+key+”=([^&#]*)”);  var qs = regex.exec(window.location.href);  if(qs == null)    return default_;  else    return qs[1];}The getQueryStringValue function is simple to use. Let’s say you have the following URL:http://www.themoderneducation.com?YourName=TMEand you…

Read More