Skip to main content
Inspiring
March 30, 2016
Answered

access cfc component

  • March 30, 2016
  • 2 replies
  • 785 views

I create a cfc which has one method and want to access from cfm file using jQuery.

it seems that jQuery does not recognize the component,\

I remember that I can check if this component and method is accessible from my browser, but I do not remember how.

Your help and information is great appreciated,

Regards,

Sourises,

This topic has been closed for replies.
Correct answer nic_tunney

You can test the component by navigating to http://mysite.com:port/MyCFC.cfc?method=myMethod

Change the above URL to meet you environment.  For instance it might be something like http://localhost:8500/model/remoting.cfc?method=login

As a quick aside, make sure you have set the CFC access to "remote".

2 replies

WolfShade
Legend
March 31, 2016

If you are using a form to submit via AJaX to a CFC:

$('#submitBtn').on('click', function(e){

    e.preventDefault(); // prevents form from standard submit

    var $formData = $('#formName').serializeArray(); // Since this is submitting via AJaX, the submit button will not be included in the form scope

    var $urlData = "//www.domain.com/components/myCFC.cfc?method=myFunction"; //As nic pointed out, change this to fit your environment

    $.ajax(

        url: $urlData,

        data: $formData

        )

        .done(

           // Process code for successful action

                );

    });

This is what I typically use.  Different scenarios have different settings.

HTH,

^_^

iccsiAuthor
Inspiring
March 31, 2016

Thanks a million for helping and information,

Regards,

Sourises,

nic_tunneyCorrect answer
Inspiring
March 31, 2016

You can test the component by navigating to http://mysite.com:port/MyCFC.cfc?method=myMethod

Change the above URL to meet you environment.  For instance it might be something like http://localhost:8500/model/remoting.cfc?method=login

As a quick aside, make sure you have set the CFC access to "remote".