Can jquery ajax post return more then 1 variable?

I am trying to do a comment system with jquery and ajax, sometimes I require a user to enter a captcha image when they are posting too often. I am using the facebox plugin for jquery with is a popup type dialog box, I am triggering this box to open, when the backend script tells it that the user needs to enter a captcha, it then pops up the box and loads the php captcha file on screen. This is where I am having trouble, I need the box to not only open the captcha, but to also populate the comment into this box into like a hidden form field, so that if a user enters the correct captcha code, it will then post there comment, otherwise, they are approving the captcha and then nothing will happen, so I need to then post the comment. Also if they get the captcha wrong, then I need to reload the captcha again with there comments still there, that should be easy if I can get the first part working. Here is my code so far for this part, can anyone help? $.ajax({ type: "POST", url: "process.php", data: args, cache: false, success: function (data) { // there was an error so we will show an error message if (data == 'error') { alert(data); //we need the user to submit a captcha to post there data } else if (data == 'captcha') { jQuery.facebox(function () { jQuery.facebox({ ajax: 'captchabox.php' }) }) //everything is all good, let post there comment } else { $('#comments').prepend(data); $(this).remove(); }) }; // remove loading image $('#load').fadeOut(); } });

以上就是Can jquery ajax post return more then 1 variable?的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » jQuery 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏