function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

remoteFunciton() doesn't work on Safari or Chrome: 401 Unauthorized as Result. IE or FF works



I use remoteFunction-calls in my visualforce pages. It turns out, that this funcionality only works in IE and FF, not in Safari.


It's easy to reproduce:


* Create a RemoteSite with Remote Site URL: ""; set the Disable Protocol Security Option

* Create a Page:


<apex:page >
<apex:includeScript value="/soap/ajax/21.0/connection.js"/>
<apex:form >
<apex:commandButton immediate="true" action="javascript&colon;test()" onclick="test(); return false;" value="Test"/>

<script type="text/javascript">
function test() {
async : true,
cache : false,
requestData: 'GET /',
method: "GET",
url : '',
onSuccess : function(response) { alert('OK: '+response); },
onFailure : function(response) { alert('ERROR: '+response); }

* havigate to /apex/yourpagename and click on the Test-Button


on FF or IE an alert is called with the contents of the google page

in Safari I get this response:


<html><head><title>401 Unauthorized</title></head>
<h1>401 Unauthorized</h1>
<p /><hr />


Can somebody verify that? I tested on 2 different PCs, but with the same development organisation.







don't you guys use remoteFunction() in your visualforce-pages ?


I just encountered this today and figured out a solution by chance.


You will need to add the following before the remoteFunction


sforce.connection.sessionId = "{!$Api.Session_ID}";