2011-06-13 72 views
0
<link rel="stylesheet" type="text/css" href="js/anytime.css" /> 

<script> 
$(document).ready(function(){ 

      $("#addsession").submit(function() { 

        $('.container_add_sesssion').show(); 

        var answer=confirm ("are you sure you want to ADD this SESSION ?");    

        if (answer) { 

           // first hide any error messages 

            $('.container_add_session').html(" processing please wait");         
            $.post('add-session-process.php', $("#field1").serialize(), function(data) { 
                     $('#replace').hide(); 
                     $('#replace').fadeIn(1500); 
                     $('#replace').html(data); 
                     $('#replace').append("<br>image goes here") 

                             }); 
                      return false; 
       }else{ 
       return false; 
       } 
       $('.container_add_session').hide(); 

      }); 
    }); 

    </script> 

<style type="text/css"> 
#field1 { color: #333333; background-image:url("clock.png"); 
    background-position:right center; background-repeat:no-repeat; 
    border:1px solid #7f7f7f;font-weight:bold} 
    #AnyTime--field1 {background-color:#EFEFEF;border:1px solid #CCC} 
    #AnyTime--field1 * {font-weight:bold} 
    #AnyTime--field1 .AnyTime-btn {background-color:#F9F9FC; 
    border:1px solid #CCC;color: #333333} 
    #AnyTime--field1 .AnyTime-cur-btn {color: red; background-color: #fcf9f6; 
     border:1px solid #191919;} 
    #AnyTime--field1 .AnyTime-focus-btn {border-style: inset} 
    #AnyTime--field1 .AnyTime-lbl {color:black} 
    #AnyTime--field1 .AnyTime-hdr {background-color: #ff6666; color:white} 
    #field2 { color: #333333; background-image:url("clock.png"); 
    background-position:right center; background-repeat:no-repeat; 
    border:1px solid #7f7f7f;font-weight:bold} 
    #AnyTime--field2 {background-color:#EFEFEF;border:1px solid #CCC} 
    #AnyTime--field2 * {font-weight:bold} 
    #AnyTime--field2 .AnyTime-btn {background-color:#F9F9FC; 
    border:1px solid #CCC;color: #333333} 
    #AnyTime--field2 .AnyTime-cur-btn {color: red; background-color: #fcf9f6; 
     border:1px solid #191919;} 
    #AnyTime--field2 .AnyTime-focus-btn {border-style: inset} 
    #AnyTime--field2 .AnyTime-lbl {color:black} 
    #AnyTime--field2 .AnyTime-hdr {background-color: #ff6666; color:white} 
</style> 

<script type="text/javascript" src="js/anytime.js"></script> 
    <h2>Dates and Sessions</h2> 

<p class="details" > 

<?php 
session_start(); 

print_r($_SESSION); 
// if edit get the showname form database, make ita session variableand echo it 
if ($_SESSION['doevent']=='edit'){echo "Editing - ".$_SESSION['showname'];} 

?> 
</p> 
    <div id="insidetabmain"><! start form area> 

    <div id="insidetableft"> 
<form id="addsession" action=""> 



    <dt id="event_date"><label for="event_date" class="required">Date and Time of session:</label></dt> 

    <input type="text" id="field1" size="50" value="" /><br/> 
    <dt id="event_date"><label for="event_date" class="required">Doors Open:</label></dt> 

    <dt><input type="text" id="field2" value="" /><br></dt> 
    <dt><br><input type="submit" id="submit" class="button" value="add session" /><BR><BR></dt> 

    </form> 


<div class="container_add_session"> 
</div> 

</div><!end leftbar> 



    <div id="insidetableft"><! second side bar> 



    <div id="replace"> 
    This area will show dates as they are added: 

    </div> 


    </div> 

</div> 

<script type="text/javascript"> 
     AnyTime.picker("field1", 
      { 

      ajaxOptions: { url: "add-session-process.php"}, 

      format: " %Y ,%W, %M, %D, Time : %H:%i ", firstDOW: 1 , 
      baseYear: 2011, 
      latest: new Date(2014,11,31,23,59,59) 

      }); 

     $("#field2").AnyTime_picker(
      { 
      ajaxOptions: { url: "add-session-process.php" }, 

      format: "%H:%i" 

      }); 
</script> 
+0

出於某種原因,消息disapeared。我試圖通過一個串行化數據的ajax post調用來發送所有的數據(見上文)。我可以得到單獨的(get)帖子,但沒有數據通過我的標準ajax調用轉移。爲什麼不 !!我如何處理我的PHP處理腳本中的單獨調用。 – 2011-06-13 15:15:10

回答

0

您正在序列化您的$.post()函數中的錯誤數據。

試試這個:

$.post('add-session-process.php', $(this).serialize(), function(data){ 
    // rest of code to process AJAX response 
});