这里是我自己刚学习用的一种间接的方法,思路是利用一个input标签把php放进去,然后通过调用这个input标签的id来实现把值传递给ajax,以方便下一步在其他php文件中使用。仅供参考。
html代码如下:
<!--head调用ajax-->
<script type="text/javascript" src="https://code.jquery.com/jquery-3.0.0.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#ggym").click(function(){
var ndyming = $("#ndym").val();
$.post('ggym.php',{oid:oiding},function(data){
alert(data);
})
})
})
</script>
然后:
<tr>
<td width="15%" align="right" valign="top">订单号:</td>
<td><input type="text" id="oiding" readonly=true value="<?php echo $oid; ?>"></td>
</tr>
如果想要看不出来,可以把input标签设置成hide。