Skip to main content
Participant
July 30, 2015
Question

Invoke a ColdFusion function via URL

  • July 30, 2015
  • 1 reply
  • 3171 views

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 has been closed for replies.

1 reply

Carl Von Stetten
Legend
July 30, 2015

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.

Participant
July 31, 2015

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

Inspiring
July 31, 2015

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?