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
__ 

Visualforce Remoting: Parameter length does not match remote action parameters

What does it mean? 

 

I am trying to do remote javascripting in visualforce. Controller is setup, but when I call function, javascript debugger in chrome gives me this error... function does not take any parameters and simply returns 'Hello' string when is called... Any help would be great.

Best Answer chosen by Admin (Salesforce Developers) 
Shashikant SharmaShashikant Sharma

Use your one i tested with remotetest, forgot to change

 

jQuerySampleController.closeOpportunity(handleCloseOpportunity);
      
      function handleCloseOpportunity(result, event) {
          if(event.type == 'exception') {
              alert(event.message);
          } else {
             var  msg = result;
              alert(msg);
          }
      }

 

All Answers

Shashikant SharmaShashikant Sharma

Could you please share your code

__

This is the script part 

 

message = jQuerySampleController.closeOpportunity();
                
               alert( message );

 this is the controller

 

global class jQuerySampleController{

@RemoteAction
    global static String closeOpportunity() {
    
    return 'Hello';
    
    }    
    
}

 

Shashikant SharmaShashikant Sharma

Do it like this

 

 

remoteTest.closeOpportunity(handleCloseOpportunity);
      
      function handleCloseOpportunity(result, event) {
          if(event.type == 'exception') {
              alert(event.message);
          } else {
             var  msg = result;
              alert(msg);
          }
      }

 

This is a callback function which handels the output of method invoke through js remoting.

__

where is remoteTest class ? 

Shashikant SharmaShashikant Sharma

Use your one i tested with remotetest, forgot to change

 

jQuerySampleController.closeOpportunity(handleCloseOpportunity);
      
      function handleCloseOpportunity(result, event) {
          if(event.type == 'exception') {
              alert(event.message);
          } else {
             var  msg = result;
              alert(msg);
          }
      }

 

This was selected as the best answer
__

so do you have to use it like that all the time? is there more ducumentation on remote javascript anywhere other that those two examples in the release?  It worked. Thanks.

Shashikant SharmaShashikant Sharma

Your welcome ,

Even though there is no document but thats a standard way of doing any ajax call, if you have in touch of .net you will see smilar in c#. even you will see similar syntax in Apex webservice methods those are invoked via java script.

Ankit AroraAnkit Arora

I have blogged something related to JavascriptRemoting, hope this will help you.

 

http://forceguru.blogspot.com/2011/06/summer-11-features-part-2-javascript.html

 

Thanks

Ankit Arora

Blog | Facebook | Blog Page

__

This helps. Awesome blog dude! Lot's of useful stuff.

 

Thank you.

Ankit AroraAnkit Arora

Glad that you liked it.

 

Thanks

Ankit Arora

Blog | Facebook | Blog Page