【问题标题】:How to build ajax paths for .cfc files in a plugin?如何在插件中为 .cfc 文件构建 ajax 路径?
【发布时间】:2013-10-21 01:53:36
【问题描述】:

在我的插件中,我定义了一个自定义远程函数。以下是内容:

<cfcomponent output="false">
<cffunction name="getPersons" access="remote" output="false">
<cfset var local = {}>

<cfquery name="local.getPersons" >
  SELECT FirstName FROM Persons
</cfquery>
<cfreturn local.getPersons>
</cffunction>
</cfcomponent>

该函数定义在文件 mytest.cfc 中,该文件存储在 displayObjects/cfc 目录下。

在存储在 displayObjects 目录中的 main.cfm 文件中,我需要对 mytest.cfc 中的函数进行 ajax 调用。

我想知道如何构建正确的路径。

调用#$.getCurrentURL()# 返回:

 http://localhost:8888/mymura/default/

但是,我需要以某种方式构建并指定以下指定 URL 路径到我的 ajax 查询:

http://localhost:8888/mymura/plugins/MyTest1_2/displayObjects/cfc/mytest.cfc

谁能告诉我存储插件特定的 .cfc 文件的推荐方法是什么以及如何正确构建访问它们的完整路径?

提前感谢您的帮助。

问候,
彼得

编辑:我快到了:

<cfoutput>
  <a href="#$.currentURL() & pluginConfig.getDirectory()#/displayObjects/cfc/myquery.cfc">My other file</a>
</cfoutput>

这会返回:

http://localhost:8888/mymura/default/MyTest1_2/displayObjects/cfc/mytest.cfc

代替:

http://localhost:8888/mymura/plugins/MyTest1_2/displayObjects/cfc/mytest.cfc

方法$.currentURL() 返回localhost:8888/mymura/default。我只需要找到一种方法来遍历一个目录并附加“插件”。

感谢任何帮助。

【问题讨论】:

    标签: coldfusion mura


    【解决方案1】:

    您可以使用站点的域设置来构建 URL:

    $.siteConfig().getDomain() & "/plugins/" & pluginConfig.getDirectory() & /displayObjects/cfc/myquery.cfc
    

    【讨论】:

    • 感谢您的帮助。 $.siteConfig().getDomain() 只返回“localhost”。我需要“localhost:8888/mymura”。我可以调用其他方法吗?问候。
    猜你喜欢
    • 2011-01-25
    • 1970-01-01
    • 1970-01-01
    • 2015-12-14
    • 2012-01-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多