cfapplication停止bind/Ajax功能?
我正在使用 mySQL 进行 ColdFusion。 我遇到绑定和自动建议功能的问题。
如果只运行这个单个文件,自动建议或绑定正在工作,我可以通过自动建议获得结果。
<cfinput type="text"
name="Name"
maxlength="100"
size="30"
required="yes"
message="Restaurant name is required!"
validateAt="onSubmit, onServer" autosuggest="cfc:Restaurants.LookupRestaurant({cfautosuggestvalue})">
但是在我添加 application.cfm 后,开始
<cfapplication name="cfcentral"
sessionmanagement="true"
sessiontimeout="#CreateTimeSpan(0,0,30,0)#"
/>
<cfset application.dsname="suman">
<cfset request.dsname="suman">
<cfset session.profile=StructNew()>
<cfif IsDefined("Form.logout")>
<cflogout>
</cfif>
<cflogin>
<cfif NOT IsDefined("cflogin")>
<cfinclude template="loginform.cfm">
<cfabort>
然后我的问题开始发生,自动建议或绑定没有更多功能。 有些人建议我添加
<cfajaximport tags="cfform">
但它无法解决问题。
我发现,如果我添加一个,并删除下面的代码,绑定就可以工作。
<cfoutput query="loginQuery">
<cfform action="#CGI.script_name#?#CGI.query_string#" name="test">
<a href="##">#First_Name# #Last_Name#</a>
<input type="submit" Name="Logout" value="Logout">
但上面的代码对我来说很重要。有人知道该解决方案可以与上面的代码完美配合吗?
这是我原来的application.cfm
<cfapplication name="cfcentral"
sessionmanagement="true"
sessiontimeout="#CreateTimeSpan(0,0,30,0)#"
/>
<cfset application.dsname="suman">
<cfset request.dsname="suman">
<cfset session.profile=StructNew()>
<cfif IsDefined("Form.logout")>
<cflogout>
</cfif>
<cflogin>
<cfif NOT IsDefined("cflogin")>
<cfinclude template="loginform.cfm">
<cfabort>
<cfelse>
<cfif cflogin.name IS "" OR cflogin.password IS "">
<cfoutput>
<h2>You must enter text in both the User Name and Password fields. </h2>
</cfoutput>
<cfinclude template="loginform.cfm">
<cfabort>
<cfelse>
<cfquery name="loginQuery" dataSource="Reservation">
SELECT *
FROM User_Customer
WHERE
Email = '#cflogin.name#'
AND Password = '#cflogin.password#'
</cfquery>
<cfif loginQuery.User_Customer_ID NEQ "">
<cfloginuser name="#cflogin.name#" Password = "#cflogin.password#"
roles="#loginQuery.User_Customer_ID#">
<cfelse>
<cfoutput>
<H2>Your login information is not valid.<br>
Please Try again</H2>
</cfoutput>
<cfinclude template="loginform.cfm">
<cfabort>
</cfif>
</cfif>
</cfif>
</cflogin>
<cfif GetAuthUser() NEQ "">
<cfquery name="loginQuery" dataSource="Reservation">
SELECT *
FROM User_Customer
WHERE Email = '#GetAuthUser()#'
</cfquery>
<cfoutput query="loginQuery">
<cfform action="#CGI.script_name#?#CGI.query_string#" name="test">
<a href="##">#First_Name# #Last_Name#</a>
<input type="submit" Name="Logout" value="Logout">
</cfform>
</cfoutput>
</cfif>
I am doing ColdFusion with mySQL.
I face a problem with bind and autosuggest function.
If just run this single file, the autosuggest or bind is working , i can get the result with autosuggest.
<cfinput type="text"
name="Name"
maxlength="100"
size="30"
required="yes"
message="Restaurant name is required!"
validateAt="onSubmit, onServer" autosuggest="cfc:Restaurants.LookupRestaurant({cfautosuggestvalue})">
But after i add an application.cfm , start with
<cfapplication name="cfcentral"
sessionmanagement="true"
sessiontimeout="#CreateTimeSpan(0,0,30,0)#"
/>
<cfset application.dsname="suman">
<cfset request.dsname="suman">
<cfset session.profile=StructNew()>
<cfif IsDefined("Form.logout")>
<cflogout>
</cfif>
<cflogin>
<cfif NOT IsDefined("cflogin")>
<cfinclude template="loginform.cfm">
<cfabort>
Then my problem start happen, the autosuggest or bind have no more function.
Some people suggest i addon
<cfajaximport tags="cfform">
But it fail to solve the problem.
i found out , if i add a , and remove the code below , the bind is working.
<cfoutput query="loginQuery">
<cfform action="#CGI.script_name#?#CGI.query_string#" name="test">
<a href="##">#First_Name# #Last_Name#</a>
<input type="submit" Name="Logout" value="Logout">
But the code above is important to me. Anyone know the solution can work perfect with the code above ?
This is my original application.cfm
<cfapplication name="cfcentral"
sessionmanagement="true"
sessiontimeout="#CreateTimeSpan(0,0,30,0)#"
/>
<cfset application.dsname="suman">
<cfset request.dsname="suman">
<cfset session.profile=StructNew()>
<cfif IsDefined("Form.logout")>
<cflogout>
</cfif>
<cflogin>
<cfif NOT IsDefined("cflogin")>
<cfinclude template="loginform.cfm">
<cfabort>
<cfelse>
<cfif cflogin.name IS "" OR cflogin.password IS "">
<cfoutput>
<h2>You must enter text in both the User Name and Password fields. </h2>
</cfoutput>
<cfinclude template="loginform.cfm">
<cfabort>
<cfelse>
<cfquery name="loginQuery" dataSource="Reservation">
SELECT *
FROM User_Customer
WHERE
Email = '#cflogin.name#'
AND Password = '#cflogin.password#'
</cfquery>
<cfif loginQuery.User_Customer_ID NEQ "">
<cfloginuser name="#cflogin.name#" Password = "#cflogin.password#"
roles="#loginQuery.User_Customer_ID#">
<cfelse>
<cfoutput>
<H2>Your login information is not valid.<br>
Please Try again</H2>
</cfoutput>
<cfinclude template="loginform.cfm">
<cfabort>
</cfif>
</cfif>
</cfif>
</cflogin>
<cfif GetAuthUser() NEQ "">
<cfquery name="loginQuery" dataSource="Reservation">
SELECT *
FROM User_Customer
WHERE Email = '#GetAuthUser()#'
</cfquery>
<cfoutput query="loginQuery">
<cfform action="#CGI.script_name#?#CGI.query_string#" name="test">
<a href="##">#First_Name# #Last_Name#</a>
<input type="submit" Name="Logout" value="Logout">
</cfform>
</cfoutput>
</cfif>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最有可能的是,您的 Ajax 调用被重定向到登录页面。 Firebug 可以告诉你这一点。它将向您显示 Javascript 中的任何错误,并且可以向您显示 Ajax 请求的结果,这很可能是您的登录表单,而不是您的预期结果(CFC 方法执行的结果)。
我建议您使用 Firebug 并了解更多有关正在发生的事情的信息。
Most likely, your Ajax call is being redirected to the login page. Firebug could tell you this. It will show you any errors in the Javascript, and it can show you the results of the Ajax request, which is most likely your login form rather than your expected result which would be the results from the CFC method execution.
I suggest you use Firebug and find out a bit more about what is happening.