Invoke ColdFusion function using AJAX(使用 AJAX 调用 ColdFusion 函数)
问题描述
当用户单击链接时,我需要调用 ColdFusion 函数(存在于 .cfm 文件中).我想用jQuery来做.我有一个 jQuery 片段,看起来像-
I need to invoke a ColdFusion function(present in a .cfm file) when the user clicks on a link. And I would like to do it using jQuery. I have a jQuery snippet which looks like-
<script type="text/javascript">
$(document).ready(function(){
$("td.ViewLink a").click(function(event){
event.preventDefault();
)}
我对 jQuery 和 AJAX 都很陌生,所以在这里我可能听起来很幼稚.我应该使用 AJAX 来调用 ColdFusion 函数吗?类似于请求在服务器上执行特定功能.
I am new to both jQuery and AJAX, so I might sound naive here. Should I use AJAX to invoke the ColdFusion function? Something like requesting to execute a specific function on the server.
感谢您提供这方面的任何帮助.
Any help in this regard is appreciated.
干杯.
推荐答案
如果您的 cfm 中有多个函数(即使您没有),请将它们放在 cfc 中.然后你可以使用下面的 url 模式来调用特定的方法.
If you have multiple functions in your cfm(even if you don't), put them in a cfc. Then you can use the following url pattern to invoke a specific method.
cfc 命名为 myEntityWS.cfc
cfc named myEntityWS.cfc
<cfcomponent>
<cffunction name="updateDescription" access="remote" returntype="string">
<cfargument name="value" type="string" required="yes">
<cftry>
your code here
<cfcatch>
<cfoutput>
#cfcatch.Detail#<br />
#cfcatch.Message#<br />
#cfcatch.tagcontext[1].line#:#cfcatch.tagcontext[1].template#
</cfoutput>
</cfcatch>
</cftry>
</cffunction>
</cfcomponent>
Javascript
$.get('myEntityWS.cfc?method=updateDescription&value=someValue');
这篇关于使用 AJAX 调用 ColdFusion 函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:使用 AJAX 调用 ColdFusion 函数


基础教程推荐
- 检查 HTML5 拖放文件类型 2022-01-01
- Bootstrap 模态出现在背景下 2022-01-01
- 如何添加到目前为止的天数? 2022-01-01
- Fabric JS绘制具有活动形状的多边形 2022-01-01
- 原生拖动事件后如何获取 mouseup 事件? 2022-01-01
- Bokeh Div文本对齐 2022-01-01
- npm start 错误与 create-react-app 2022-01-01
- 在 contenteditable 中精确拖放 2022-01-01
- fetch 是否支持原生多文件上传? 2022-01-01
- 即使用户允许,Gmail 也会隐藏外部电子邮件图片 2022-01-01