You need to sign in to do that
Don't have an account?
VisualForce and AJAX
Hi
I am writing my 1st visual force page and it is housed under setup-develop-pages
The code is very simple -
<apex:page showHeader="false" sidebar="false" >
<apex:includeScript value="/soap/ajax/15.0/connection.js"/>
<apex:includeScript value="/soap/ajax/15.0/apex.js"/>
<script>
function setupPage() {
sforce.connection.sessionId = '{!$Api.Session_ID}';
alert(sforce.connection.sessionId);
var queryResult = sforce.connection.describeTabs();
alert('after query');
} //end function
</script>
<body onload="setupPage();">
<div id="output">HI</div>
</body>
</apex:page>
I am getting the 1st alert message with the session id, but the alert after api call is giving an error - {faultcode:'UNKNOWN_EXCEPTION', faultstring:'UNKNOWN_EXCEPTION: Site under construction', }
Can someone please help me with this.
thanks
I am also facing the same error - {faultcode:'UNKNOWN_EXCEPTION', faultstring:'UNKNOWN_EXCEPTION: Site under construction', }
Did u get to know why this error comes?
The following actually works. The "onload" doesn't work as suggested in the documentation:
<html>
<head><apex:includeScript value="/soap/ajax/17.0/connection.js"/>
<script type="text/javascript">
function displayTabs(tabs) {
var tab = tabs[i];document.write(
" " + tab.label + " " + tab.url + " " + tab.iconUrl + " " + tab.miniIconUrl + " " + tab.sobjectName );document.write("<br />");
}}
try {var
result = sforce.connection.describeTabs();} catch(error) {
document.write(error);}for
(var i=0; i < result.length; i++) {var tabSet = result[i];document.write (tabSet.label);
document.write("<br />");
var tabs = tabSet.get("tabs");displayTabs(tabs);
}
</script></head>
<body >
</html>
</apex:page>
Took me almost 3 days to sort through the mis-information and many hours of trial and error to get this.
Let me know if you find a way to send this information to the underlying controller.
Enjoy.
Note that "alert" don't work in Visualforce per another piece of random documentation.
Would be nice if they could put the rules for proper use of javascript within Visualforce all in one place.