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, 2017 at 6:28
  • I want to use the page as javascript that's why I specified the contentType="text/javascript" Mar 30, 2017 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, 2017 at 6:31
  • I want to load the js at runtime using require js Mar 30, 2017 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, 2017 at 6:36

2 Answers 2


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

  • It doesn't work for me Mar 31, 2017 at 7:10

@hitesh-gupta i would do the following based on W3C standards.


Based on https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_page.htm there is no contentType attribute called text/javascript, so not sure if it is supported by Salesforce.

You might want to refer the available type attributes here [https://www.w3schools.com/tags/att_script_type.asp]

FYI based on IANA, text/javascript is OBSOLETE, refer the below link http://www.iana.org/assignments/media-types/media-types.xhtml


So you VF page should have the below

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

Let me know if it helps.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .