![](/img/trans.png)
[英]How to Use PHP text-box value in PHP variable, without page reload and without using JavaScript (Ajax)
[英]AJAX open link without page reload and PHP get variable
page.php
<script>
$(document).ready(function(){
// Set trigger and container variables
var trigger = $('.a'),
container = $('#content');
// Fire on click
trigger.on('click', function(){
// Set $this for re-use. Set target from data attribute
var $this = $(this),
target = $this.data('target');
// Load target page into container
container.load(target + ".php?id=<?php echo $_POST['id']?>");
// Stop normal link behavior
return false;
});
});
</script>
<nav id="nav">
<ul>
<form method="post">
<input name="id" value="12">
</form>
<li><a id="home" class="a" href="#" data-target="home">Home</a></li>
<li><a id="about" class="a" href="#" data-target="about">About</a></li>
</ul>
</nav>
<div id="content">
<style>
#home{display:none;}
</style>
<h1>Home</h1>
<p>This is the home page</p>
<h3>
</h3>
</div>
about.php
<h1>about</h1>
home.php
<h1>home</h1>
腳本AJAX可以很好地工作,沒有負載它可以打開內容無限,但問題是行數。 PHP當我嘗試通過POST方法在其他內容上發送ID時,它將無法正常工作。
您的問題不清楚。 假設您嘗試通過AJAX發送“ id”作為get參數,並在div / section中加載內容。
最好將$ _POST替換為$ _REQUEST,並用“ isset”包圍。
在表單上執行操作。 將名稱和ID放在表單值上。 如
<input name="id" name="id" value="12">
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.