I am searching for a solution to use a page as javascript and to make the remote action calls to the server. Here is the code of the page that I created

 <apex:page standardStylesheets="false" showChat="false" showHeader="false" Controller="CustomerOrderCtrl" 
    sidebar="false" applyHtmlTag="false" applyBodyTag="false" contentType="text/javascript">

    var service = angular.module("ctrl1Service_PK", []);

    service.factory('CustomerInfoService', ['$q', function ($q) {
        return {
            EditCustomerDetails: function (customerId) {
                customerId = window.btoa(customerId);
                var deferred = $q.defer();

                // make AJAX request to the remote service
                var abc;


                Visualforce.remoting.Manager.invokeAction('{!$RemoteAction.CustomerOrderCtrl.getCustomer}', customerId, function(result, event) {
                    if(event.type == 'exception') {
                    } else {
                        var customer = window.atob(result);
                        var find = '\'';
                        var re = new RegExp(find, 'g');
                        customer = customer.replace(re, '');
                }, {
                    escape: true
                return deferred.promise;

Controller class

global static String getCustomer(String customerId){
    //Some code here
    return BPUtility.getEncodedString('');


I am getting this error

Unable to invoke action 'CustomerOrderCtrl.getCustomer': no controller and/or function found

  • did you try by removing or changing content-type? – Ashwani Mar 30 '17 at 6:28
  • I want to use the page as javascript that's why I specified the contentType="text/javascript" – Hitesh Gupta Mar 30 '17 at 6:30
  • Never seen anyone using contentType="text/javascript", What is the use case? Maybe you should try using Visualforce Components. – Raul Mar 30 '17 at 6:31
  • I want to load the js at runtime using require js – Hitesh Gupta Mar 30 '17 at 6:32
  • Its okay to use content-type but did you check by removing the content-type to make sure this attribute is the reason? – Ashwani Mar 30 '17 at 6:36

try removing remote action and {! / } : Visualforce.remoting.Manager.invokeAction('CustomerOrderCtrl.getCustomer'',

In other words you want to call a remote actions from a page without a controller, like a static resource. Javascript Remoting in Static Resource

| improve this answer | |
  • It doesn't work for me – Hitesh Gupta Mar 31 '17 at 7:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.