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
ImpactMGImpactMG 

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

Hi,

 

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: "http://www.google.at"; 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"/>
</apex:form>

<script type="text/javascript">
function test() {
sforce.connection.remoteFunction({
async : true,
cache : false,
requestData: 'GET /',
method: "GET",
url : 'http://www.google.at',
onSuccess : function(response) { alert('OK: '+response); },
onFailure : function(response) { alert('ERROR: '+response); }
});
}
</script>
</apex:page>

* 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>
<body>
<h1>401 Unauthorized</h1>
<p /><hr />
<small></small>
</body>

 

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

 

thx

impactit

ImpactMGImpactMG

hi,

 

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

XhitmanXhitman

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}";