cfajaxproxy 的简单表单不起作用
表单无法正常工作,无法通过 CFC 发布到数据库,或者似乎正在使用脚本。当您单击“发表评论”按钮时,没有任何反应。我只花了一天的时间尝试了很多很多不同的事情。不同的按钮和不同的代码,有些让事情变得更糟,大多数只是出现错误或刷新页面。我在下面的代码中没有收到任何错误,但没有任何反应。
谁能看到我在做什么吗?
表单
脚本
function PostComment() {
var cfc = new PostCommentCFC();
cfc.setCallbackHandler(getComment);
cfc.Comment(true); var targetPostCommentResponse = document.getElementById("targetPostCommentResponse").style.display='block';
var targetMakeComment = document.getElementById("targetMakeComment").style.display='none';
$('#OpenMakeCommentResponse').html("发表评论");
$('#CloseMakeCommentResponse').html("");
返回假;
}
CFC PostComment
<cfcomponent>
<cffunction name="PostComment" access="remote">
<cfargument name="CommentSection" type="string" required="true" />
<cfargument name="Comment" type="string" required="true" />
<CFQUERY NAME="Comment" DATASOURCE="MyDSN">
INSERT INTO Comments(ID,Comment,CommentSection,CommentDate)
VALUE (#COOKIE.ID#,'#arguments.Comment#',#arguments.CommentSection#,#Now()#)
</CFQUERY>
<cfreturn true>
</cffunction>
</cfcomponent>
Form is not working, does not post to the database though the CFC or seem to be working with the script. When you click on the PostComment button nothing happens. I just spent a day and tried many, many different things. Different buttons and different code, some made things worse and most just cased errors or refreshed the page. I’m not getting any errors with the code below but nothing happens ether.
Can anyone see what I am doing worng?
form
<CFFORM NAME="PostComment" ID="PostComment" METHOD="POST" onsubmit="return false;">
<CFINPUT TYPE="hidden" NAME="CommentSection" VALUE="#CommentSec#">
<CFtextarea name="Comment" rows="10" cols="50"></CFtextarea>
<CFINPUT type="image" name="Submit" id="PostComment" value="Post Comment" src="images/PostComment.gif" width="70" height="15" onmouseover="src='images/PostCommentOVER.gif'" onmouseout="src='images/PostComment.gif'">
</CFFORM>
script
<cfajaxproxy cfc="CFC/PostComment" jsclassname="PostCommentCFC">
function PostComment() {
var cfc = new PostCommentCFC();
cfc.setCallbackHandler(getComment);
cfc.Comment(true);
var targetPostCommentResponse = document.getElementById("targetPostCommentResponse").style.display='block';
var targetMakeComment = document.getElementById("targetMakeComment").style.display='none';
$('#OpenMakeCommentResponse').html("make a comment");
$('#CloseMakeCommentResponse').html("");
return false;
}
CFC PostComment
<cfcomponent>
<cffunction name="PostComment" access="remote">
<cfargument name="CommentSection" type="string" required="true" />
<cfargument name="Comment" type="string" required="true" />
<CFQUERY NAME="Comment" DATASOURCE="MyDSN">
INSERT INTO Comments(ID,Comment,CommentSection,CommentDate)
VALUE (#COOKIE.ID#,'#arguments.Comment#',#arguments.CommentSection#,#Now()#)
</CFQUERY>
<cfreturn true>
</cffunction>
</cfcomponent>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我没有检测到您的代码有任何问题,并且我广泛使用 cfajaxproxy。这可能是一些小事。
我将使用 firebug 和名为 Coldfire 的 firebug 的 Coldfusion 扩展进行调试,该扩展可在 RIAForge http://riaforge.org 上找到,并使用调试器如果您使用 ColdFusion Builder,则可以使用 Cold Fusion,并且在较小程度上作为 cfeclipse 的一部分。
祝你好运
I don't detect anything wrong with your code and I use cfajaxproxy extensively. It is probably something little.
I would debug using firebug and the coldfusion extension to firebug called coldfire available at RIAForge http://riaforge.org and use the debugger for Cold Fusion available if you are using ColdFusion Builder and to a lesser extent as part of cfeclipse.
Good luck