我想知道我是否可以post
将表单中的数据发送到其他页面上的特定div。比方说,
form.php的
我在jQuery中有这个代码:
$("#hod").change(function(){
var hod = $('#hod').val();
$.post('calc.php #content',
{
hod : hod
}, function(data){
$('#designation').html(data)
});
});
calc.php
<?php
if(isset($_POST['budget'])){
$budget=$_POST['budget'];
$paid=$_POST['paid'];
$ammount=$_POST['ammount'];
$gst=$_POST['gst'];
}
$total=$budget+$paid+$ammount+$gst;
echo $total;
?>
<div id="content">
<?php
if(isset($_POST['hod'])){
$hod=$_POST['hod'];
}
require '../db_connection/connection-intra.php';
$sql="SELECT s.nama,s.staff_id,gp.jawatan,j.nama_jabatan from staff s INNER JOIN gred_pekerja gp ON s.gred_id=gp.gred_id INNER JOIN jabatan j ON j.j_id=s.j_id WHERE s.staff_id='$hod'";
$result=mysqli_query($conn, $sql);
if(!$result) {
die(mysqli_error($conn));
}
if(mysqli_num_rows($result) > 0){
while($row=mysqli_fetch_assoc($result)){
$jawatan=$row['jawatan'];
$jabatan=$row['nama_jabatan'];
}
}
mysqli_free_result($result);
mysqli_close($conn);
echo $jawatan." ".$jabatan;
?>
</div>
如果我将post
值发送到页面 calc.php ,则它还将取值<div id="content"></div>
之外的值。有没有办法只在<div>