在你前面的問題,你的標籤看,我以爲你是不是太瞭解AJAX的。
您需要
1.post異步形式(不重新加載頁面,使用AJAX)。
2.成功發送數據後,執行dom操作。
我建議使用jQuery做AJAX文章。
這裏是一個示例代碼,使用jQuery: -
$('#guest_details').load('?p=guest_details.html');
$('#first_start').load('?p=first_start.html')
function ajaxPostForm()
{
$.post('guest_details.php',
function(data) {
//Dom manipulation
$('#guest_details').hide('slow');
$('#first_start').SlideUp('slow')
});
}
而且裏面guest_details.html
需要你的HTML表單是這樣的: -
<form method="POST" id="guest">
<!-- Some cell here -->
<a onclick="ajaxPostForm();" class="button" id="first_start"> <span> <?php echo $button_submit;?> </span> </a>
</Form>
上面給出的$。員額是一個非常基本的AJAX帖子。您可以在Jquery Post中添加更多功能。
此外,如果你要發佈整個表格,你可以參考jQuery Form Plugin
更新
我想我明白你的問題好這段時間。您的更新裏,你說這個 -
默認guest_details.html是 顯示和first_start.html藏匿
指的是部分爲guest_details
和first_start
會更有意義,因爲guest_details.html
可能意味着您可能已在另一個窗口中打開的頁面guest_details.html
。
無論如何,我相信你的意思是頁面process.html
內部的部分,因爲你已經使用jquery。我們稱first_start.html
和guest_details.html
分別爲first_start
和guest_details
。
根據你更新你的意思如下: -
科guest_details
顯示和first_start
隱藏
案例/情境初始狀態
當內部guest_details
部分形式是提交,然後隱藏部分guest_details
並顯示first_start
部分。
在此狀態下,當隱藏guest_details
並顯示first_start
時,可點擊first_start
上的按鈕,然後再次點擊guest_details
部分。
在這些狀態下,一個部分被隱藏,另一個顯示重新加載/刷新頁面應該保持狀態。
如果上面是完整的場景,這裏是代碼: -
<script>
<! -
initiateSections(<?php echo $this->session->data['display_state']; ?>);
//state can have "display_first_start" or "display_guest_details"
function initiateSections(state)
{
$('#guest_details').load('?p=guest_details.html');
$('#first_start').load('?p=first_start.html')
if(state == "display_first_start")
{
displayFirstStart();
}
else
{//If chosen or by default
displayGuestDetails();
}
}
function ajaxPostGuestDetails()
{
$.post('guest_details.php', //In this post request - set $this->session->data['display_state'] = 'display_first_start'; in php
function(data)
{
//Dom manipulation
displayFirstStart();
});
}
function ajaxPostFirstStart()
{
$.post('first_start.php', //In this post request - set $this->session->data['display_state'] = 'display_guest_details';
function(data)
{
//Dom manipulation
displayGuestDetails();
});
}
function displayGuestDetails()
{
$('#first_start').hide('slow');
$('#guest_details').slideUp('slow');
}
function displayFirstStart()
{
$('#guest_details').hide('slow');
$('#first_start').slideUp('slow');
}
->
</Script>
你甚至張貼使用AJAX的形式? – 2010-11-25 18:53:58
btw:`.SlideUp('slow')`應該是`.slideUp('slow')` – 2010-11-25 18:59:10
你的html失敗了,窗體標籤中的一個表單:P。驗證你的代碼一段時間。 – 2010-11-25 18:59:54