You need to sign in to do that
Don't have an account?
regger118
Apex webservice from ajax on sites page not working
if i disable showheader it failes calling the apex webservice but if i enable show headers it works on the sites page why is this?
Uncaught {faultcode:'UNKNOWN_EXCEPTION', faultstring:'UNKNOWN_EXCEPTION: Site under construction', }
It would be nice if you could provide some more info and some code where you are facing this problem. One direction that I can suggest to you is that when showHeader is disabled some standard style and javascripts are removed , please check whether it is not causing the issue. If so then add that style of javascript in your page.
Here is some code
this line in particular
now if i don't show header this does not work, otherwise if enabled the apex ajax works on the sites page.
I have made sure that the sites user has this visual page enabled and has access to the objects in question and checked field level security.
I have implemented it , that time it was working perfectly, but now suddenly it is broken, Now the remote action is returning to an error saying "unable to connect to the server" . Its unstable feature.
This issue actually appears to revolve around a problem with accessing webservices anonymously.
The only solution I was able to find was to set a userId and siteUrlPrefix:
UserContext.initialize({"userId":"005c0000000IktF","siteUrlPrefix":"/leadimport"});
and include the salesforce main.js [I downloaded it while the headers were on then saved it as a static resource]:
<apex:includeScript value="{!URLFOR($Resource.jqueryPackage, 'js/main.js')}"/>
library manually.
The solution offered by Salesforce support:
var __sfdcSessionId = '{!GETSESSIONID()}';
does not actually allow my site call to work as intended [I would still get a Site Under Construction error]:
POST https://everbank.ewmqa.cs14.force.com/services/Soap/package/PortalUserResetWS 500 (Internal Server Error) connection.js:599
Uncaught {faultcode:'UNKNOWN_EXCEPTION', faultstring:'UNKNOWN_EXCEPTION: Site under construction', } connection.js:1019
The same error is reported on these pages
http://boards.developerforce.com/t5/Force-com-Sites/Apex-webservice-from-ajax-on-sites-page-not-working/td-p/290173
http://boards.developerforce.com/t5/Force-com-Sites/sforce-apex-execute-giving-error-in-Sites-hosted-on-Prod-org-na6/m-p/138463#M978
Personally, I think it is ridiculous that once you say that the PAGE has access to the webservice that you need any userid at all but for now the workaround allows the page to do what it needs to do. I certainly don't believe I should need to download the main.js (which may not work after a future upgrade) and set a userId and siteUrlPrefix. Salesforce really should allow you to configure a webservice to work without a userid for their sites pages.
<apex:includeScript value="soap/ajax/31.0/connection.js"/>
to:
<script src="soap/ajax/31.0/connection.js"></script>
Apparently, when you use "<apex:includeScript>", the script is inserted before the standard salesforce scripts, but when you use <script> directly, your script runs after the salesforce scripts; it looks like one of the standard scripts needed to run before connection.js to get it to work correctly in the portal.