Skip to main content
Participant
Jul 30, 2015 11:44 AM UTC
Question

Invoke a ColdFusion function via URL

Hi I'm trying to invoke a ColdFusion function via typing in a URL in the web address bar such as:

http://domain.com/path/to/your.cfc?method=functionName&argument1=arg1Val

I have to do it this way for testing purposes. How can I invoke the following below function "showWinDOTD();" from the script below via URL? I have tried continuously the following with no luck:

http://site.com/act/actCart.cfm?method=showWinDOTD

http://site.com/act/actCart.cfm?method=showWinDOTD

Am I missing something simple?

<script>

  var refreshInterval = 0;

  var winFlag = false;

  $(function() {

  if(refreshInterval>0)

  {

  setTimeout('location.reload();',refreshInterval);

  }

  });

    function submitForm() {

        ColdFusion.Ajax.submitForm('DOTDform','/act/actCart.cfm',callback,errorHandler);

    }

    function selectDOTD(input,promoID,optionID)

  {

  input.disabled = true;

  formObj = input.form;

  formObj.PromoID.value = promoID;

  formObj.OptionID.value = optionID;

        ColdFusion.Ajax.submitForm(formObj.name,'/act/actCart.cfm',callback,errorHandler);

    }

  function callback(text)

  {

  text = (text.replace(/^\s+|\s+$/g,"")).toUpperCase();

  if(text=='ADDED')

  window.location = 'https://www.site.com/checkout/cart.cfm?uiID=16';

  else if(text=='MAXED')

  window.location = 'https://www.site.com/checkout/cart.cfm?uiID=43';

  else if(text=='SOLD')

  {

  if(!winFlag)

  {

  winFlag = true;

  showWinDOTD();

  }

  else

  {

  ColdFusion.Window.onHide('results',showWinDOTD);

  ColdFusion.Window.hide('results');

  }

  }

  else {

  window.location = '/';

  }

  }

  function errorHandler(code, msg)

    {

       showWinDOTD();

    }

  function reloadPage()

  {

  window.location.reload();

  }

  function showWinDOTD()

  {

  ColdFusion.Window.show('results');

  ColdFusion.Window.onHide('results',reloadPage);

  }

</script>

This topic is closed to new replies. Start a new post to keep the conversation going.

7 replies

Carl Von Stetten
Legend
Jul 30, 2015 6:20 PM UTC

Hard to answer without seeing the content of your CFC (or at least then entire block defining the function you are having issues with).  Have you specified access="remote" in your function definition?

-Carl V.

Translate
Participant
Jul 31, 2015 2:20 AM UTC

I've posted the entire block defining the function in the lower part of my post. Is that what you are looking for?

Translate
Inspiring
Jul 31, 2015 8:03 AM UTC

All you have posted is Javascript functions. There is nothing there related to a Coldfusion CFC???

Do you mean you are trying to execute a JAVASCRIPT function when the page loads?

Translate