drjun1994 2014-12-13 07:39
浏览 55

FancyBox表单提交

I have been looking around online on how to get a web form to work inside of FancyBox. The form displays correctly, but when I press submit, it submits and adds a row to the database, but everything is blank (meaning its not really adding the data). In addition to this, it does not show a response to say if the message has been sent in the lightbox or not. I reviewed other questions similar to this and found out that AJAX is used to submit it. Ive never really used AJAX before so I am not for sure what is wrong. I have also used FireBug and it does not show any data transmitting.

Code for Form:

<div style="display: none">
<div id="contact">
This form will allow you to contact our staff support team. This can be used to request ban     reversals, login problems, etc. Just note, all responses will be sent via e-mail.<br />Be sure you  leave us a valid e-mail and to be sure you check this email often and to check your spam folders if you do not receive a response.<br /><br /><center>
<form action="" method="post" id="contactus">
Your Name:  <input type="text" STYLE="color: black;  background-color: white;" name="name" value="" /><br />
Your Email: <input type="text" STYLE="color: black;  background-color: white;" name="email" value="" /><br /><br />
Your Message: <br /><br /><textarea rows="10" cols="70" STYLE="color: black;  background-color: white;" name="textarea" value=""></textarea><br /><br />
<input type="submit" STYLE="color: black;  background-color: white;" value="Submit Message" />    </form><br /></center>
</div>
</div>

Here is the AJAX Function

<script type="text/javascript">
$(document).ready(function() {
    $(".fancybox").fancybox();
});
</script>

$("#contact").bind("submit", function() {

    $.fancybox.showActivity();

    $.ajax({
        type        : "POST",
        cache       : false,
        url         : "outsidesupport_processed.php",
        data        : $(this).serializeArray(),
        success     :function(data){
                        $.fancybox(data);
                     }
    });

    return false;
});

});     
</script>
  • 写回答

1条回答 默认 最新

  • dream04110 2014-12-13 07:44
    关注

    Debugg data add alert(data); in success

    success :function(data){
                               $.fancybox(data);
                               alert(data);
                         }
    

    Are there any errors?

    This is syntax error:

    </script>
    
    $("#contact").bind("submit", function() {
    

    check var test = $(this).serializeArray(); if test is not null, maybe error is here outsidesupport_processed.php

    评论

报告相同问题?

悬赏问题

  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示