简体   繁体   English

FancyBox PHP表单提交问题

[英]FancyBox PHP form submit issue

Okay, so I've been having a problem for the past four days, and a couple hours ago, I think I may have solved part of it (fancybox example #5, on their site, seems to be something that I want), however, I cannot get any part of it to work. 好的,过去四天来我一直遇到问题,几个小时前,我想我可能已经解决了一部分问题(他们网站上的fancybox示例#5似乎是我想要的东西),但是,我无法发挥任何作用。

    <?  if($_GET['page'] != "startTime"){ ?>
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
    <script type="text/javascript" src="/./fancybox/jquery.mousewheel-3.0.2.pack.js"></script>
    <script type="text/javascript" src="/./fancybox/jquery.fancybox-1.3.1.js"></script>
    <link rel="stylesheet" type="text/css" href="/./fancybox/jquery.fancybox-1.3.1.css" media="screen" />
    <script type="text/javascript">
        $(document).ready(function() {
            $("#startTime").fancybox({
            'padding'       : 0,
            'scrolling'     : 'no',
            'titleShow'     : false,
            'onClosed'      : function() {
            $("#login_error").hide();}
            })
        });
        $("#startTimeForm").bind("submit", function() {
        if ($("#year").val().length < 4) {
            $("#login_error").show();
            $.fancybox.resize();
            return false;
        }
        $.fancybox.showActivity();
        $.ajax({
            type    : "POST",
            cache   : false,
            url     : "downTime.php?page=ajax",
            data    : $(this).serializeArray(),
            success : function(data) {
                $.fancybox(data);
            }
        });
        return false;
        });
    </script>
<? } ?>
<? if($_GET['page'] == "ajax"){
var_dump($_POST); } ?>
<? if($_GET['page'] == "startTime"){?>
<div style="width:250px" class="new">
  <table cellpadding="0" cellspacing="0" border="0" width="100%" class="new">
   <tr>
   <form id="startTimeForm" method=post>
    <p id="login_error">Please, enter data</p>
   <tr>
    <td>Enter Year</td>
    <td><input class="czas" id="sec" name="year" type="text" size="5" maxlength="5" value="00" /></td></tr>
   <tr>
    <td colspan="2" align="center"><br /><input class="czas" type="submit" name="newTime" value="Set Start Time" /></td></tr>
   </form>

I also had used a javascript function, below, and I'd eventually like that to work in the code above, but I cannot get the above to work properly. 我还在下面使用了javascript函数,最终希望在上面的代码中使用它,但是我无法使上面的代码正常工作。 It just does nothing. 它什么也没做。 Firebug also reports no errors. Firebug也未报告任何错误。

<script>
    function closeFB() {
    <? $unix = mktime(0, 0, 0, 1, 1, $_POST['year']); ?>
    $("#startTimeDiv").html("<div id='message'></div>");
    $("#message").html("<p>Contact Form Submitted!</p>")
    .append("<p>We will be in touch soon.<br><? echo $unix; ?></p>");
    $.fancybox.close(); 
    }
    </script>

So, any help would be appreciated. 因此,任何帮助将不胜感激。 Please tell me what I'm doing wrong. 请告诉我我在做什么错。

The demonstration here worked to solve the problem. 这里的演示可以解决该问题。 It created another problem, but that is for another question. 它造成了另一个问题,但这是另一个问题。 I believe that was your demo, JFK, so thank you. 我相信这是您的演示,肯尼迪(JFK),谢谢。

$.ajax({
        type    : "POST",
        cache   : false,
        url     : "downTime.php?page=ajax",
        data    : $(this).serializeArray(),
        success : function(data) {

Instead of: 代替:

            $.fancybox(data);

Try 尝试

            $("#fancyboxdiv").fancybox(data);

        }
    });

Where fancyboxdiv is the name of your element that hosts the fancybox. 其中fancyboxdiv是承载fancybox的元素的名称。

You will change the other functions to 您将其他功能更改为

$("#fancyboxdiv").fancybox().close() 

etc.. Most JQuery UI components require a element to work off of as its parent and it will usually modify that element adding/removing elements to it and changing CSS to give appearance that is needed 等等。大多数JQuery UI组件都需要一个元素作为其父元素来工作,它通常会对该元素进行修改,从而向其中添加/删除元素并更改CSS以提供所需的外观

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM