<th>是否推广</th> <td> {if condition='$vo.dis eq 0'} <a onclick="dodis(this,'{$vo.dis}','{$vo.id}')" style="color:red; font-size:16px;font-weight:600" href="#">是</a> {else /} <a onclick="dodis(this,'{$vo.dis}','{$vo.id}')" style="color:grey;font-size:16px;font-weight:600" href="#">否</a> {/if} </td>
js:
<script> function dodis(obj,dis,id){ $.ajax({ url:"{:U('wxnumber/dis')}", type:"post", data:{'dis':dis,'id':id}, dataType:'json', success:function(data){ window.location.reload(); }, }); } </script>
php:
public function dis(){ $wx = M('wxnumber'); if (IS_POST) { $id = I('id'); $dis = I('dis'); if ($dis == 0) { $wx->id=$id; $wx->dis=1; $data = $wx->save(); }else{ $wx->id=$id; $wx->dis=0; $data = $wx->save(); } $this->ajaxReturn($data); } }