【发布时间】:2010-11-18 11:36:02
【问题描述】:
我正在开发社交网络上的评论系统,我正在使用 jquery,我可以毫无问题地使用 ajax 发布 cmets,但有时我需要用户提交验证码表单,如果他们发布了太多 cmets 或其他原因。
我认为最好的方法是将它添加到当前的评论发布部分,如果 php 脚本返回一个响应,说明我们需要做一个验证码表单,那么我想自动打开一个对话框屏幕上的窗口,让用户填写验证码表格,然后继续并在那里发表评论。
这对我来说有点复杂,但我认为我已经完成了大部分工作,也许你可以阅读下面的我的 cmets 并帮助我处理验证码部分,主要是关于如何触发打开对话框,如何通过通过验证码评论值/文本并在成功时再次返回评论,如果用户验证码错误,那么它将重新加载验证码
$.ajax({
type: "POST",
url: "processing/ajax/commentprocess.php?user=",
data: args,
cache: false,
success: function (resp) {
if (resp == 'captcha') {
//they are mass posting so we need to give them the captcha form
// maybe we can open it in some kind of dialog like facebox
// have to figure out how I can pass the comment and user data to the captcha script and then post it
} else if (resp == 'error') {
// there was some sort of error so we will just show an error message in a DIV
} else {
// success append the comment to the page
};
}
});
【问题讨论】: