迅睿開源框架是一款PHP8高性能·簡單易用的PHP開源開發(fā)框架, 基于MIT開源許可協(xié)議發(fā)布,不限制商業(yè)使用,以多端互聯(lián)為設(shè)計理念, 支持的微信公眾號、小程序、APP客戶端、移動端網(wǎng)站、PC網(wǎng)站等多終端式管理系統(tǒng)。
業(yè)務(wù)經(jīng)理
微信掃描以上二維碼
028-61286886
技術(shù)咨詢
想要實現(xiàn)一個按鈕字段,實現(xiàn)點擊一次增加一個,麻煩問下大神怎們寫
$(function(){ $("#點擊加1").click(function(){ dr_show_hits($id); });
肯定不能這么寫啊,dr_show_hits是php函數(shù)啊,你要把dr_show_hits的js拿出來放到j(luò)s函數(shù)里面
<li onclick="hits('huaquan')">
function hits(data){ $.ajax({ type: "POST", url: "/index.php?s=photo&c=home&m=hits&id="+{$id}+"&type="+data, success: function(data){ }, error: function(data){ } }) }
public function hits(){ $id = $this->input->get('id', true); $type = $this->input->get('type', true); $hits = $this->db->select('huaquan')->where('id',$id)->get(SITE_ID.'_photo')->result_array(); $huaquan = $hits[0]['huaquan']+1; $result = $this->db->where('id', $id)->update(SITE_ID.'_photo', ['huaquan'=>$huaquan]); if($result){ return json_decode(['code'=>1]); }else{ return json_decode(['code'=>0]); } }
肯定不能這么寫啊,dr_show_hits是php函數(shù)啊,你要把dr_show_hits的js拿出來放到j(luò)s函數(shù)里面
<li onclick="hits('huaquan')">function hits(data){ $.ajax({ type: "POST", url: "/index.php?s=photo&c=home&m=hits&id="+{$id}+"&type="+data, success: function(data){ }, error: function(data){ } }) }public function hits(){ $id = $this->input->get('id', true); $type = $this->input->get('type', true); $hits = $this->db->select('huaquan')->where('id',$id)->get(SITE_ID.'_photo')->result_array(); $huaquan = $hits[0]['huaquan']+1; $result = $this->db->where('id', $id)->update(SITE_ID.'_photo', ['huaquan'=>$huaquan]); if($result){ return json_decode(['code'=>1]); }else{ return json_decode(['code'=>0]); } }