• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Invoke a ColdFusion function via URL

New Here ,
Jul 30, 2015 Jul 30, 2015

Copy link to clipboard

Copied

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>

Views

2.5K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jul 30, 2015 Jul 30, 2015

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 30, 2015 Jul 30, 2015

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jul 31, 2015 Jul 31, 2015

Copy link to clipboard

Copied

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 31, 2015 Jul 31, 2015

Copy link to clipboard

Copied

Hi Haxtbh, yes, all I want to do is manually run the showWinDOTD(); function via URL, I'm guessing that that is a Javascript. How can I run it for testing? Basically, when showWinDOTD(); function runs, it gives me a pop up window. I need to test this pop up window.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Aug 01, 2015 Aug 01, 2015

Copy link to clipboard

Copied

If you just  want to run the javascript when the page has loaded, call the function on the body tag onload attribute.

<body onload="showWinDOTD();">

.....

</body>

If you want to do it just when the url param is passed then just check for the param then run the function.

<body <cfif structKeyExists(url, 'method') AND url.method EQ 'showWinDOTD'>onload="showWinDOTD();"</cfif>>

....

</body>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 01, 2015 Aug 01, 2015

Copy link to clipboard

Copied

Is there anyway to run this function via URL without having to edit the actual website file? That's what I'm looking for.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Aug 01, 2015 Aug 01, 2015

Copy link to clipboard

Copied

LATEST

No,

Its javascript. You are trying to pass URL vars for coldfusion to do something with, but the function you want to call is not coldfusion, its javascript.

You will need to edit the page to pass the url variables. After all, it needs to know what you are trying to do.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation