我有网络电子商务,它使用传递代理网站的API rajaongkir.com, 我想使用传递代理的价格是我的数据库中的变量。从内部发送变量php内部
她是文件order.php
<script type="text/javascript" src="js/script.js"></script>
<form action="input.php?input=inputform" method="post">
<table class="zebra-table">
<thead>
<tr>
<th>Kurir</th>
<th>Servis</th>
<th>Deskripsi Servis</th>
<th>Lama Kirim (hari)</th>
<th>Total Biaya (Rp)</th>
<th>Opsi</th>
</tr>
</thead>
<tbody id="resultsbox"></tbody>
</table>
的script.js
function cekHarga(){
//var origin = $('#oricity').val();
var origin = 35;
var destination = $('#descity').val();
var weight = $('#berat').val();
var courier = $('#service').val();
$.ajax({
url:'process.php?act=cost',
data:{origin:origin,destination:destination,weight:weight,courier:courier},
success:function(response){
$('#resultsbox').html(response);
},
error:function(){
$('#resultsbox').html('ERROR');
}
});
}
process.php
if(isset($_GET['act'])):
switch ($_GET['act']) {
$cost = $IdmoreRO->hitungOngkir($origin,$destination,$weight,$courier);
//parse json
$costarray = json_decode($cost);
$results = $costarray->rajaongkir->results;
if(!empty($results)):
foreach($results as $r):
foreach($r->costs as $rc):
foreach($rc->cost as $rcc):
echo "<tr><td>$r->code</td><td>$rc->service</td><td>$rc->description</td><td>$rcc->etd</td><td>".number_format($rcc->value)."</td> <td></td></tr>";
$bayarr=$rcc->value;
endforeach;
endforeach;
endforeach;
endif;
}
endif;
我可以在形式访问变量$ bayarr在order.php。
如何发送变量$ bayarr在process.php到order.php?
你的问题有些含糊。如果你想把这个变量“发送”到'order.php',那么头部重定向('header(“Location:order.php”);')就是你要找的东西。如果你想使用order.php中的函数,你可以使用类方法(定义,包括和启动)。请更确切地说明你真正想要的东西。 – Jan
当我尝试所有代码粘贴在这里,它说错误张贴。我在PHP编程中太小气了。我会学到更多。 thx寻求建议 – Hafidh