1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
         //我要提問基於tp3.2
            public function tiwen(){
                $cityId = parent::$cityId;//區分城市id
                $typeDb=D("FangType");
                $typeData=$typeDb->getConfig(36,$cityId);
                $this->assign("typeData",$typeData);
                if($_POST){
                $db = D("EsfAsk");
                $userid=  $this->userId;
                $asktypeid=I(`asktypeid`);
                $asktitle=I(`asktitle`);
                $data[`askType`] = $asktypeid;
                $data[`askTitle`] = $asktitle;
                $data[`description`] =$asktitle;
                $data[`askTime`] = time();
                $cookie = cookie(`bresfwd`);
                cookie(`bresfwd`,"Y",array(`expire`=>60));
                if($cookie){
                      $this->success(`提交過於頻繁`);
                
                
                 
                $data[`cityId`]=$cityId;
                $data[`userId`] = $userid;
                $data[`isAnswer`] = `N`;
                $data $db->add($data);
                if ($data) {
                    $this->success(`提交成功`);
                else {
                    $this->success(`提交失敗`);
                }
             }
                $this->display(); 
            }
js程式碼:
<!--提問-->
<script>
    function tijiao(){
     var asktypeid=document.getElementsByClassName(`active`)[0].value;
   
      var asktitle=$("#askTitle").val();    
       
      $.post("/Esf/Ask/tiwen",{asktypeid:asktypeid,asktitle:asktitle},function(data){
            if(data.status==1){
             layer.msg(data.info);//根據返回提示
             window.location.href=window.location.href;
       
            }else {
                
         layer.msg("提交失敗");
         
        }
          }); 
        }