New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CFAjaxproxy not starting from root. #25

Closed
minifiredragon opened this Issue Feb 25, 2016 · 4 comments

Comments

Projects
None yet
3 participants
@minifiredragon

minifiredragon commented Feb 25, 2016

CFInvoke properly starts from root when used. However, CFAjaxproxy starts from the directory it is in and never goes out to root. I am not sure how I can put a code sample in because there is no way to show that it is not working correctly inside the code block, as it is not the code example that is the issue.

CFML Document:

Javascript side:
sCFC = new stampsClass();

CFML Document location:
/public_html/amazon/stamps.cfm (example)

CFC location:
/cfc/stamps.cfc

When page is run, CJAjaxproxy fails:

Type Application
Detail A request was made to a resource that could not be located
Missing File cfc.stampss
Tag Context CFAJAXPROXY (/public_html/amazon/stamps.cfm, Line=7, Column=1)
Source

4 :
5 : <title>Order Fulfillment</title>
6 :
7 :

But if you use cfinvoke component="cfc.stamps" it will function as it should.

@MFernstrom

This comment has been minimized.

Show comment
Hide comment
@MFernstrom

MFernstrom Apr 4, 2018

Member

@minifiredragon That follows the Adobe implementation, but I added a new optional parameter called siteroot which will let you start from there instead.

So just use siteroot="true" and it'll append / to the path and let you hit CFCs from the root on up.

Member

MFernstrom commented Apr 4, 2018

@minifiredragon That follows the Adobe implementation, but I added a new optional parameter called siteroot which will let you start from there instead.

So just use siteroot="true" and it'll append / to the path and let you hit CFCs from the root on up.

@minifiredragon

This comment has been minimized.

Show comment
Hide comment
@minifiredragon

minifiredragon Apr 7, 2018

Thank you. I do have 1 question though, with out this, how does one get out of the directory they are in and access a cfc in another directory? I have been writing cffunctions that use cfinvoke to get to a different folder since all I can do is go deeper in the current directory and nothing else.

minifiredragon commented Apr 7, 2018

Thank you. I do have 1 question though, with out this, how does one get out of the directory they are in and access a cfc in another directory? I have been writing cffunctions that use cfinvoke to get to a different folder since all I can do is go deeper in the current directory and nothing else.

@MFernstrom

This comment has been minimized.

Show comment
Hide comment
@MFernstrom

MFernstrom Apr 8, 2018

Member

RPC endpoints are super easy to work with, but cfajaxproxy makes it even simpler.

Without it you'd have to not use cfajaxproxy but directly call the CFC and function like so:

http://www.AwesomeSite.com/components/coolComponent.cfc?method=myFunction&mydata=123

Assuming your component lives under the subfolder components.

Specify returnformat="JSON" in your function and you're all set.

Example:

Save to your root directory as mycomp.cfc and you can call it with "/mycomp.cfc?method=getPosts&authorId=123" from any AJAX client.

component {
  remote struct function getPosts( required numeric authorId ) returnformat="JSON" {
    try {
      var params = [ { value: argumetns.authorId, cfsqltype: "cf_sql_integer" } ];
      var data = queryRun( "yourdsn", "SELECT id, body FROM posts WHERE authorId = ?", params );
      return { success: true, data: queryToArray( data ) };
      
    } catch( any e ) {
      return { success: false, error: e.message, details: e };
    }
  }
}
Member

MFernstrom commented Apr 8, 2018

RPC endpoints are super easy to work with, but cfajaxproxy makes it even simpler.

Without it you'd have to not use cfajaxproxy but directly call the CFC and function like so:

http://www.AwesomeSite.com/components/coolComponent.cfc?method=myFunction&mydata=123

Assuming your component lives under the subfolder components.

Specify returnformat="JSON" in your function and you're all set.

Example:

Save to your root directory as mycomp.cfc and you can call it with "/mycomp.cfc?method=getPosts&authorId=123" from any AJAX client.

component {
  remote struct function getPosts( required numeric authorId ) returnformat="JSON" {
    try {
      var params = [ { value: argumetns.authorId, cfsqltype: "cf_sql_integer" } ];
      var data = queryRun( "yourdsn", "SELECT id, body FROM posts WHERE authorId = ?", params );
      return { success: true, data: queryToArray( data ) };
      
    } catch( any e ) {
      return { success: false, error: e.message, details: e };
    }
  }
}
@MFernstrom

This comment has been minimized.

Show comment
Hide comment
@MFernstrom

MFernstrom Apr 9, 2018

Member

I think this can be closed now

Member

MFernstrom commented Apr 9, 2018

I think this can be closed now

@wua22 wua22 closed this Apr 9, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment