You need to sign in to do that
Don't have an account?
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,
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
check your remote security settings and why not just use apex to callout to ur vf page?
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
look at the apex docs here http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_restful_http.htm
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
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
or my function
public static String getContent()
is responsible for this?
Thanks