簡體   English   中英

提交數據時如何避免jquery“ colorbox”關閉

[英]How to avoid the jquery “colorbox” closing when we are submitting the data

我通過使用Jquery colorbox中的ajax方法調用外部php頁面,因為在我提交數據時,colorbox自動關閉n轉到沒有lightbox的普通頁面視圖如何避免這種情況,並在提交后重新打開colorbox。 ...

請告訴我一些建議,解決這個問題的朋友... //////

 <script src="jquery/jquery.colorbox-min.js"></script>
    <script>
        $(function(){
            $(".ajax").colorbox({width:"63%", height:"80%"})
        });
</script>
<a class="ajax" href="assign_ajax.php">New Task</a>

這是使用顏色////////////////////// /// ajax頁面////////////////////////

if(isset($_POST['update'])){ 

$sql = UPDATE `notes` SET `note`=$_POST['update_text'] WHERE`id`={$_GET['note_id']};
mysql_query($sql) or die(mysql_error());
}


<form name="update_form" id="update_form" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);>?note_id=<?php echo $row['id']; ?>" method="post">
<textarea name="update_text" id="update_text" rows="5" cols='55'><?php echo $row['note']; ?></textarea>
<br>
<input type="submit" id="update" name="update" value="update">
<input type="button" value="cancel" class ="edit" id="edit-<?php echo $row['id']; ?>">
</form>
<script src="jquery/jquery.colorbox-min.js"></script>
<script>
    function showColorBox(event)
    {
       event.preventDefault();
       $.colorbox({href:"assign_ajax.php"});
    }
</script>
<a class="ajax" onclick="showColorBox(event)">New Task</a>
//Or
<script src="jquery/jquery.colorbox-min.js"></script>
<script>
    $(function(){
        $(".ajax").on("click",function(event){
             event.preventDefault();
             $.colorbox({href:$(this).attr("href")});
        });
    });
</script>
<a class="ajax" href="assign_ajax.php">New Task</a>

編輯

<?php
if(isset($_POST['update'])){ 
    $sql = "UPDATE `notes` SET `note`=$_POST['update_text'] WHERE`id`={$_GET['note_id']}";
    mysql_query($sql) or die(mysql_error());
}
?>


<form name="update_form" id="update_form" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']);>?" note_id="<?php echo $row['id']; ?>" method="post" onsubmit="return FALSE;">
<textarea name="update_text" id="update_text" rows="5" cols='55'><?php echo $row['note']; ?></textarea>
<br>
<input type="button" id="update" name="update" value="update">
<input type="button" value="cancel" class ="edit" id="edit-<?php echo $row['id']; ?>">
</form>
<script>
    $(function(){
        $("#update").on("click",function(){
             $.ajax({url: $("#update_form").attr("action"), data:{note_id: $("#update_form").attr("note_id"),update_text:$("#update_text").val()}, type:"POST", dataType:"json"}).done(function(data){});
        });
    });
</script>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM