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
Anand PatelAnand Patel 

Calling controller method from javascript Golbal Remote call is not working

Hello,


I am creating a multiple file upload, one of the thing that is failing for me is "Calling controller method from javascript, Golbal Remote call for is not working"

So I created a simple example to test and that not working either, Here is my Controller class and page, Its not showing me a alert on page load.  What am I doing wront here ?

Class
===========

global with sharing class myControllerTest {
    
    @RemoteAction
    global static String getID(String parentId){
        return parentId;
    }
}




Page
============

<apex:page >
<head>
   <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"/>
   <script type="text/javascript">
     j$=jQuery.noConflict();
     
     myControllerTest.getID('Hello Salesforce', function(result,event){
        if(event.status == true){
            alert(result);
        }else{
            alert(event.message);
        }
    }, {escape: false});
   </script>
</head>   
  <!-- Begin Default Content REMOVE THIS -->
  <h1>Congratulations</h1>
  <!-- End Default Content REMOVE THIS -->
</apex:page>

SFDC_VikashSFDC_Vikash

Hi

 

It is displaying an alert box on page load with message "Hello Salesforce" . I above case you have only missed to specify controller on page as follows :

 

<apex:page controller="myControllerTest">

 

 Please mark it as solution if it works for you so that others can use this.

Anand PatelAnand Patel

Thanks for reply.

 

I am getting this error now

 

 I tried in 2 Development enviornment and Sandbox.

 

Dev enviornment I dont get any alert at all

 

Sandbox I am getting error - Unable to determine from which page the request originated

S91084S91084

Hi Anannd,

 

How are you invoking the function in thne javascript. When does your javascript gets executed?

 

Please refer to the example provided in the below link.

 

Remote Action in Visualforce Page

sham_1sham_1

Hi Anand,

Were you able to find a workaround for the issue.

I am also receiving the error, while trying to invoke remote action from Firefox

 

 

jhennyjhenny

Something to do with sending http referer headers - this fixed it for me:

 

Go to your firefox config - type "about:config" in the address bar,

 

Then look for the setting "network.http.sendRefererHeader;"

 

Right click it and select "reset"