How to use Ajax on Visualforce page on Salesforce platform
Just use Ajax pattern to call object data from server on visualforce page.
Following is the Asynchronise demo:
<apex:page >
<script type="text/javascript">
var __sfdcSessionId = '{!GETSESSIONID()}';
</script> <script src="../../soap/ajax/29.0/connection.js" type="text/javascript"></script> <script type="text/javascript">
window.onload = setupPage;
function setupPage(){
var state = {
output : document.getElementById("output"),
startTime : new Date().getTime()
}; var callBack = {
onSuccess : layoutResults,
onFailure : queryFailed,
source : state
}; sforce.connection.query("Select Id, Name, Industry From Account order by Industry", callBack);
} function queryFailed(error, source){
source.output.innerHTML="An error has occurred: " + error;
} function layoutResults(queryResult, source){
if(queryResult.size > 0){
var output = "";
var records = queryResult.getArray('records');
for(var i = 0; i < records.length; i++){
var account = records[i];
output += account.Id + " " + account.Name + " [Industry - " + account.Industry + "]<br>";
}
source.output.innerHTML = output;
}
} </script> <div id="output"></div> </apex:page>
If we want to use the Synchronise model. Just use the query function without callback. Following is the demo code.
sforce.connection.query("Select Id, Name, Industry From Account order by Industry")
If you want to know more about the detail. Please go to click this link: http://www.salesforce.com/us/developer/docs/ajax/apex_ajax.pdf
...................................
Another link show you another ajax call code-behind function : http://www.cnblogs.com/mingmingruyuedlut/p/3450753.html
How to use Ajax on Visualforce page on Salesforce platform的更多相关文章
- Salesforce学习之路-developer篇(三)利用Visualforce Page实现页面的动态刷新案例学习
Visualforce是一个Web开发框架,允许开发人员构建可以在Lightning平台上本地托管的自定义用户界面.其框架包含:前端的界面设计,使用的类似于HTML的标记语言:以及后端的控制器,使用类 ...
- Salesforce学习之路(六)利用Visualforce Page实现页面的动态刷新功能
Visualforce是一个Web开发框架,允许开发人员构建可以在Lightning平台上本地托管的自定义用户界面.其框架包含:前端的界面设计,使用的类似于HTML的标记语言:以及后端的控制器,使用类 ...
- 在Salesforce中向Page Layout中添加Visualforce Page
在Salesforce中可以向Object所对应的Layout中添加我们自定义的Visualforce Page. 此时的Visualforce Page与Asp.Net MVC中的Partial V ...
- Salesforce随笔: 将Visualforce Page渲染为PDF文件(Render a Visualforce Page as a PDF File)
参照 : Visualforce Developer Guide 第60页 <Render a Visualforce Page as a PDF File> 你可以用PDF渲染服务生成一 ...
- Visualforce Page CSS样式
Salesforce Page开发者文档:https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_stylin ...
- Visualforce Page超链接
Salesforce开发者文档:https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_quick_start ...
- 在Visualforce page中用自带的控件实现Ajax回调后台方法(并且可以用js去动态给parameters赋值)
这里用的组合是:apex:commandLink + apex:actionFunction + apex:outputPanel 这里的 apex:commandLink 和 apex:actio ...
- Salesforce随笔: 将Visualforce Page导出为 Excel/CSV/txt (Display a page in Excel)
想要实现如题所述功能,可以参照 : Visualforce Developer Guide 第57页中所举的例子,在<apex:page>标签中添加contentType属性. <a ...
- Ajax load html page
jQuery ajax - load() 方法 jQuery Ajax 参考手册 实例 使用 AJAX 请求来改变 div 元素的文本: $("button").click(fun ...
随机推荐
- java获取对象属性类型、属性名称、属性值
/** * 根据属性名获取属性值 * */ private Object getFieldValueByName(String fieldName, Object o) { try { String ...
- Python缩小图像
LyncLynn用途: 缩小图像 # -*- coding: UTF-8 -*- #Version: V1.0 #Author:lynclynn #CreateDate:20151201 #Updat ...
- Excel保护工作表
最近见到一个Excel文件,其中的表不能选中,不能编辑,今天研究了一下 明白了其设置方法 excel中开始--格式--保护工作表--去掉所有勾选,输入保护密码 即可
- 基于NHibernate的开发框架的设计
上次的 NHibernate的Session管理策略和NHibernateHelper 发布并提供下载,给NHibernate刚入门的同学们带来很多便利. 最近有同学在求NH的通用仓储,正好我最近也设 ...
- js中setInterval与setTimeout用法
setTimeout 定义和用法: setTimeout()方法用于在指定的毫秒数后调用函数或计算表达式. 语法: setTimeout(code,millisec) 参数: ...
- HDU 5884 Sort -2016 ICPC 青岛赛区网络赛
题目链接 #include <iostream> #include <math.h> #include <stdio.h> #include<algorith ...
- 【Python升级录】--基础知识
创建角色成功! 正在载入python........ [python介绍] python是一门动态解释性的强类型定义语言. python的创始人为吉多·范罗苏姆(Guido van Rossum).1 ...
- ajax加载模块实时刷新的原理
var loadMenu = function(data) { var trs = template.render('menu-list-temp', {'list': data}); ...
- July 9th, Week 28th Saturday, 2016
Every cloud has a silver lining. 山穷水尽疑无路,柳暗花明又一村. Every cloud has a silver lining, that just because ...
- July 7th, Week 28th Thursday, 2016
The 79th Anniversary of Anti-Japan War Difficulties vanish when faced bodly. 勇敢面对困难,困难自会退让. The best ...