Hello All, Any Fusebox user here? How can I call t...
# cfml-general
h
Hello All, Any Fusebox user here? How can I call the .cfc inside circuit.xml file and return result?
a
Long time since I used Fusebox and even longer since I used the XML version - but seem to recall the is a
<invoke>
verb you can use
<invoke object="myFusebox" methodcall="do('main.welcome')" returnvariable="x" />
@hpeter16 ^
h
Copy code
<fuseaction name="getUser">
        <instantiate object="userComponent" class="project.Model.user" />
		<invoke object="userComponent" methodcall="getUser()" returnvariable="resultData">
			<argument name="userId" value="#attributes.userId#" />
		</invoke>
	</fuseaction>
I have been calling index.cfm?fuseaction=user.getUser from the jquery post function...I can successful able to call the fuseaction but I don't get any result back
a
I'd guess you'd need a display file to show the returned data.
h
Copy code
$.ajax({
                        type: "POST",
                        url: "index.cfm?fuseaction=user.getUser",
                        data: { userId: userId},
                        success: function(resultData){
                            var result = JSON.parse(resultData);
                            if(result.SUCCESS == true){
                                //do something
                            } else {
                                bootbox.alert(result.MESSAGE);
                            }
                        }
                    });
The resultData on success of jquery post is always return empty string.
a
I refer you to my previous response:
I'd guess you'd need a display file to show the returned data.
h
I can't directly return data from cfc to fusebox and back to JS?
a
why would it?
I'm not sure if fusebox is new to you but the idea of having views is pretty much how fusebox shows data
So you need a
dsp_getUser.cfm
or whatever to render the data you want returned back to AJAX (probably using
SerializeJSON()
h
Oh, I see. I'm new to fusebox and didn't know much about its flow. I was under the impression that I should call the fusebox through JavaScript and that the fusebox would then call the .cfc, which would return data back to JavaScript.
Thanks @aliaspooryorik for your help.
👍 1
a
I assume this is an existing project you have inherited as Fusebox has not been active for years
h
yes right...Recently hired at company which use fusebox and try to figure out the flow.
a
The 'noxml' version is a lot nicer to work with and closer to modern frameworks like FW1 and ColdBox.
Looks like there are some docs which may help you get up to speed https://github.com/fusebox-framework/Fusebox-ColdFusion/tree/master/docs as the website is long gone
h
Thanks again...It's really helpful docs.
r
call index.cfm?fuseaction=user.getUser directly in browser, check what's returned. In project look for /user folder and inside look into circuit.xml for getUser fuseaction. Usually fusebox circuits has bunch of includes that have cfm files included, not CFC. Inside those cfms usually all logic is located, and it may appear it not uses CFCs at all. Not everything has to be 'incapsulated' :)
👍 1