2013-10-21 37 views
0

在我的插件,我已經定義了一個自定義的遠程功能。以下是內容:如何在插件中爲.cfc文件構建ajax路徑?

<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/ 

不過,我會以某種方式需要建立並指定下列指定我的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。我只需要找到一種方法來遍歷一個目錄並追加「插件」。

任何幫助表示讚賞。

回答

0

您可以使用該網站的域名設置構造URL:

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

謝謝您的幫助。 $ .siteConfig()。getDomain()只返回「localhost」。我需要「localhost:8888/mymura」。有沒有其他方法可以打電話?問候。 – Peter

相關問題