我有一個表格,使用下面的JS代碼在頭(form.php的):如何通過Javascript將一個php會話從一個頁面轉移到另一個頁面?
<script type="text/javascript">
$(document).ready(function(){
$("a").click(function(){
$.post('test.php', function(data) {
$('#test').html(data);
});
});
});
</script>
一個有form.php的,一旦點擊我想要一個下拉出現一個鏈接(不刷新頁面)例如「顯示下拉」。下拉菜單中的代碼在test.php中進行管理。
Test.php從另一個服務中提取數據。爲了獲得這些數據,我使用會話中保存的數據,例如$ _SESSION [ 'data_that_is_sent_to_another_service']。
我在form.php中啓動會話,但爲了讓test.php從其他服務中獲取信息,我需要在test.php開始時啓動一個會話。
代碼工作,但後來我得到一個警告說:
Warning: session_start() [function.session-start]:
Cannot send session cache limiter - headers already sent
(output started at /..my directory.../test.php:1) in /...my directory.../hrdeals.php on line 4
我怎樣才能得到這樣的警告沒有出現(沒有PHP關閉警告)?
任何幫助非常感謝。
格雷戈爾
PS - JS的可能是不正確的,但它更在SESSION的問題,我可以解決
請使用搜索:[「無法發送會話緩存限制器」](http://stackoverflow.com/search?q=%5Bphp%5D+%22cannot+send+session+cache+limiter%22&submit=search)/ [「標題已發送」](http://stackoverflow.com/search?q =%5Bphp%5D +%22headers + already + sent%22&submit = search) – Gumbo
當你收到一個包含'headers already sent'的錯誤時,它會告訴你你要做的事情*輸出(包括空格),包括「include/require」其他文件。所以你必須在輸出任何東西之前調用'session_start()'(和'header()')。 –
Gumbo謝謝你。你能推薦一個搜索引擎嗎? – gelviis