我正在开发社交网络上的评论系统,我正在使用 jquery,我可以毫无问题地使用 ajax 发布评论,但有时如果用户发布太多评论或出于其他原因,我需要用户提交验证码表单。
我认为最好的方法是将其添加到当前的评论发布部分,如果 php 脚本返回响应,说明我们需要做一个验证码表单,那么我想自动打开一个对话窗口屏幕,让用户填写验证码表格,然后继续并在那里发表评论。
这对我来说有点复杂,但我认为我已经完成了大部分工作,也许你可以阅读下面的评论并帮助我处理验证码部分,主要是关于如何触发对话框打开,如何传递评论值/通过验证码发短信并在成功时再次返回评论,如果用户验证码错误,那么它将重新加载验证码
$.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
};
}
});