我想知道是否有人可以告诉我这段代码有什么问题,因为它不起作用,也不会给我任何错误。
使用此代码,我尝试访问每次有人按下链接时更新数据库表的组件。
<cfajaxproxy bind="url:http://www.example.com/admin/CRM/linktracking.cfc" />
<cfscript>
SSLtype = (CGI.HTTPS EQ 'off')?'http://':'https://';
</cfscript>
<cfset domainname = CGI.SERVER_NAME>
<cfset domainURL = SSLtype&CGI.SERVER_NAME&CGI.SCRIPT_NAME&'?'&CGI.QUERY_STRING>
<script>
function insertTracking(href) {
var instance = new ajaxjsclass();
instance.setCallbackHandler();
<cfoutput>
instance.insertTrack(href,'#surveymain.contactid#','#domainname#','#domainURL#');
</cfoutput>
}
</script>
这是我尝试访问的组件。
<cfcomponent>
<cffunction name="insertTrack" access="remote" returntype="void" >
<cfargument name="clickedURL" required="yes">
<cfargument name="contactid" required="yes">
<cfargument name="domainName" required="yes">
<cfargument name="domainURL" required="yes">
<cfquery name="q_inserttrack" datasource="dpsigweb">
update survey_tracking
set surveystarted = <cfqueryparam value="#now()#" cfsqltype="CF_SQL_TIMESTAMP">
where contactid= '#contactid#'
</cfquery>
<cfif ARGUMENTS.contactid NEQ ''>
<cfscript>
additionalInfo = '<b>Clicked URL</b> - <i>#ARGUMENTS.clickedURL#</i><br><br><b>From Site</b> - <i>#ARGUMENTS.domainURL#</i>';
gaCFC = CreateObject("component","mod_sigweb.components.guestaccount");
gaCFC.AddCorrespondenceCurDoctorProcedureRemote(
functionPassword = 'password',
contactid = '#ARGUMENTS.contactid#',
theMessage = additionalInfo,
statustype = 'Survey Started',
contactresult ='Survey Started'
);
</cfscript>
</cfif>
</cffunction>
</cfcomponent>
这是我尝试从以下位置访问该功能的地方:
<a href="http://dev.example.com/surveys/survey.cfm?id=#id#&contactid=#contactid#&doctorid=#doctorid#" onClick="insertTracking(this.href)" >
我怀疑我的<cfajaxproxy>
标记可能有语法错误,但是当我按下链接时,我没有收到任何错误。
我将cfajaxproxy
更改为此
<cfajaxproxy cfc="linktracking" jsclassname="ajaxjsclass" />
但功能似乎仍无效。我甚至将组件和cfm文件移动到同一个文件夹中,但它仍然无效。
编辑: 我忘了提到我在电子邮件模板中发送此代码。我不知道这是否有任何影响。我创建了一个我在本地测试的测试页面,我的代码运行得很好。如果有什么需要改变的话请告诉我
答案 0 :(得分:0)
找到解决方案。我将更新查询代码直接放在页面上,因此当用户按下链接并打开页面时,查询将从那里运行,而不是从链接运行。
上面的代码工作正常我只是遇到了问题,因为我是通过电子邮件将页面发送给用户的。至少这是我怀疑的。