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
DowithforceDowithforce 

sfroce.connection.remoteFunction not working in visualforce page

Hello All,

 

For this case I have found many post but still problem was not fully solved. So here I am starting new fresh

thread for discussion.

 

As so many developers are working to convert Scontrol to VF, facing common problem for sforce.connection.remoteFunction. Following code is working fine in scontrol for all browsers, but not for VF. Only FF works for VF.

 

 

 

I have found solution acceptance on forum to add code but it is not working in my case?

 

sforce.connection.sessionId = "";

 

 

sforce.connection.remoteFunction({
url : "http://domainname/page",
mimeType: "text/plain",
requestHeaders:{"Content-Type":"application/x-www-form-urlencoded" },
method:"POST",
requestData:"checkvalue="+escape(checkvalue)+"&query="+escape(query)+"&strtodisplay="+escape(strtodisplay)+"&user_name="+escape(username),
async:"true",
onFailure:function(response) { alert(response); },
onSuccess:function(response) { alert(response)}
});

 

 What is the reason?

 

 Google chrome giving error "401 Unauthorized"  error.

 

 Reference link: http://www.christopherstoll.org/2009/04/firefox-beats-chrome-in-enterprise.html

 

 What is the soltuion to code work for all browsers?

 

 

 

 Thanks,

DowithforceDowithforce

Adding some information,

 

I have tested code in Ajax toolkit shell and its working in google chrome what I have tested, not check for all browsers.

 

Need some quick helpful response. Let see...

 

Thanks

Message Edited by Dowithforce on 11-12-2009 01:49 AM
DowithforceDowithforce
Can anybody help me out for this?
Guyver118Guyver118

check your remote security settings and why not just use apex to callout to ur vf page?

DowithforceDowithforce

Yes remote setting added. Actually my code is ready for remotefunction ajax toolkit.

but working only in FF.

 

Yes apex calling is another option can you provide me some example for this?

 

Thanks

 

 

DowithforceDowithforce

Thanks, I have implemented this, I want a HTMl response but I getting plan text as response. 

 

How I will get HTML response. How I can set header to get it?

 

Thanks

 

DowithforceDowithforce

My code is as follows

 

public static String getContent()
{


String url ='http://domainame/page';
String parameters = 'id=1';
// Instantiate a new http object
Http h = new Http();
HttpRequest req = new HttpRequest();
req.setEndpoint(url);

req.setMethod('POST');
req.setBody(parameters);//this is like parameters="var1=value1&var2=value2&var3=value3"

req.setHeader('Content-type', 'application/x-www-form-urlencoded');
req.setHeader('Content-length', String.valueOf(parameters.length()) );
req.setHeader('Accept', 'application/html');
HttpResponse res = h.send(req);
return res.getBody();

}

 

 Still my code giving me text response and showing HTML tags like plain text.

 

Thanks

DowithforceDowithforce

or my function

 

public static String getContent()

 

 

is responsible for this?

 

 

 

Thanks