本帖最后由 xuzuning 于 2014-07-01 17:05:54 编辑

解决方案 »

  1.   

    if($_POST['action'] ==  'add' ){
    条件 $_POST['action'] ==  'add' 不成立,所以 echo 不执行
      

  2.   

    var_dump($_POST['action']);//输出看看值是什么?确定条件成立?
      

  3.   

    条件是成立的,$rollback = $this->lottory_record_db->where(array('lid'=>$lid,'wecha_id'=>$wechaid,'id'=>$rid))->save($data);这句代码也是执行了的,数据库中有数据
      

  4.   

    那你输出的只是一个 json 串,需要 js 代码去解析呀
      

  5.   

    是js代码解晰的问题?
    下面这段代码在同一页面,却又能弹出提示
    public function exchange(){
    $this->lottory_record_db=M('Lottery_record');
    $this->lottory_db=M('Lottery');
    $this->lottory_pw_db=M('Lottery_pw');
     if(IS_POST){
      $Lottery_pw = $this->lottory_pw_db->where(array('dpassword'=>trim($_POST['parssword'])))->find();
           
      if ($Lottery_pw['dpassword'] != trim($this->_post('parssword'))){
      echo'{"success":0,"msg":"密码不正确"}';exit;
      }else {
      $data['sendtime'] = time(); 
      $data['sendstutas'] = 1;
                    $data['dname'] = $Lottery_pw['dname'];
                    $data['dpassword'] = $Lottery_pw['dpassword'];
      $this->lottory_record_db->where(array('id'=> intval($_POST['rid'])))->save($data);
      echo'{"success":1,"msg":"领取成功","changed":1}';
      }
    }
    }
      

  6.   

    document.writeln("<style type=\"text\/css\">");
    document.writeln("");
    document.writeln(".window {");
    document.writeln(" width:290px;");
    document.writeln(" position:fixed;");
    document.writeln(" display:none;");
    document.writeln(" bottom:30px;");
    document.writeln(" left:50%;");
    document.writeln("  z-index:9999;");
    document.writeln(" margin:-50px auto 0 -145px;");
    document.writeln(" padding:2px;");
    document.writeln(" border-radius:0.6em;");
    document.writeln(" -webkit-border-radius:0.6em;");
    document.writeln(" -moz-border-radius:0.6em;");
    document.writeln(" background-color: #ffffff;");
    document.writeln(" -webkit-box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);");
    document.writeln(" -moz-box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);");
    document.writeln(" -o-box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);");
    document.writeln(" box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);");
    document.writeln(" font:14px\/1.5 Microsoft YaHei,Helvitica,Verdana,Arial,san-serif;");
    document.writeln("}");
    document.writeln(".window .title {");
    document.writeln(" ");
    document.writeln(" background-color: #A3A2A1;");
    document.writeln(" line-height: 26px;");
    document.writeln("    padding: 5px 5px 5px 10px;");
    document.writeln(" color:#ffffff;");
    document.writeln(" font-size:16px;");
    document.writeln(" border-radius:0.5em 0.5em 0 0;");
    document.writeln(" -webkit-border-radius:0.5em 0.5em 0 0;");
    document.writeln(" -moz-border-radius:0.5em 0.5em 0 0;");
    document.writeln(" background-image: -webkit-gradient(linear, left top, left bottom, from( #585858 ), to( #565656 )); \/* Saf4+, Chrome *\/");
    document.writeln(" background-image: -webkit-linear-gradient(#585858, #565656); \/* Chrome 10+, Saf5.1+ *\/");
    document.writeln(" background-image:    -moz-linear-gradient(#585858, #565656); \/* FF3.6 *\/");
    document.writeln(" background-image:     -ms-linear-gradient(#585858, #565656); \/* IE10 *\/");
    document.writeln(" background-image:      -o-linear-gradient(#585858, #565656); \/* Opera 11.10+ *\/");
    document.writeln(" background-image:         linear-gradient(#585858, #565656);");
    document.writeln(" ");
    document.writeln("}");
    document.writeln(".window .content {");
    document.writeln(" \/*min-height:100px;*\/");
    document.writeln(" overflow:auto;");
    document.writeln(" padding:10px;");
    document.writeln(" background: linear-gradient(#FBFBFB, #EEEEEE) repeat scroll 0 0 #FFF9DF;");
    document.writeln("    color: #222222;");
    document.writeln("    text-shadow: 0 1px 0 #FFFFFF;");
    document.writeln(" border-radius: 0 0 0.6em 0.6em;");
    document.writeln(" -webkit-border-radius: 0 0 0.6em 0.6em;");
    document.writeln(" -moz-border-radius: 0 0 0.6em 0.6em;");
    document.writeln("}");
    document.writeln(".window #txt {");
    document.writeln(" min-height:30px;font-size:16px; line-height:22px;");
    document.writeln("}");
    document.writeln(".window .txtbtn {");
    document.writeln(" ");
    document.writeln(" background: #f1f1f1;");
    document.writeln(" background-image: -webkit-gradient(linear, left top, left bottom, from( #DCDCDC ), to( #f1f1f1 )); \/* Saf4+, Chrome *\/");
    document.writeln(" background-image: -webkit-linear-gradient( #ffffff , #DCDCDC ); \/* Chrome 10+, Saf5.1+ *\/");
    document.writeln(" background-image:    -moz-linear-gradient( #ffffff , #DCDCDC ); \/* FF3.6 *\/");
    document.writeln(" background-image:     -ms-linear-gradient( #ffffff , #DCDCDC ); \/* IE10 *\/");
    document.writeln(" background-image:      -o-linear-gradient( #ffffff , #DCDCDC ); \/* Opera 11.10+ *\/");
    document.writeln(" background-image:         linear-gradient( #ffffff , #DCDCDC );");
    document.writeln(" border: 1px solid #CCCCCC;");
    document.writeln(" border-bottom: 1px solid #B4B4B4;");
    document.writeln(" color: #555555;");
    document.writeln(" font-weight: bold;");
    document.writeln(" text-shadow: 0 1px 0 #FFFFFF;");
    document.writeln(" border-radius: 0.6em 0.6em 0.6em 0.6em;");
    document.writeln(" display: block;");
    document.writeln(" width: 100%;");
    document.writeln(" box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);");
    document.writeln(" text-overflow: ellipsis;");
    document.writeln(" white-space: nowrap;");
    document.writeln(" cursor: pointer;");
    document.writeln(" text-align: windowcenter;");
    document.writeln(" font-weight: bold;");
    document.writeln(" font-size: 18px;");
    document.writeln(" padding:6px;");
    document.writeln(" margin:10px 0 0 0;");
    document.writeln("}");
    document.writeln(".window .txtbtn:visited {");
    document.writeln(" background-image: -webkit-gradient(linear, left top, left bottom, from( #ffffff ), to( #cccccc )); \/* Saf4+, Chrome *\/");
    document.writeln(" background-image: -webkit-linear-gradient( #ffffff , #cccccc ); \/* Chrome 10+, Saf5.1+ *\/");
    document.writeln(" background-image:    -moz-linear-gradient( #ffffff , #cccccc ); \/* FF3.6 *\/");
    document.writeln(" background-image:     -ms-linear-gradient( #ffffff , #cccccc ); \/* IE10 *\/");
    document.writeln(" background-image:      -o-linear-gradient( #ffffff , #cccccc ); \/* Opera 11.10+ *\/");
    document.writeln(" background-image:         linear-gradient( #ffffff , #cccccc );");
    document.writeln("}");
    document.writeln(".window .txtbtn:hover {");
    document.writeln(" background-image: -webkit-gradient(linear, left top, left bottom, from( #ffffff ), to( #cccccc )); \/* Saf4+, Chrome *\/");
    document.writeln(" background-image: -webkit-linear-gradient( #ffffff , #cccccc ); \/* Chrome 10+, Saf5.1+ *\/");
    document.writeln(" background-image:    -moz-linear-gradient( #ffffff , #cccccc ); \/* FF3.6 *\/");
    document.writeln(" background-image:     -ms-linear-gradient( #ffffff , #cccccc ); \/* IE10 *\/");
    document.writeln(" background-image:      -o-linear-gradient( #ffffff , #cccccc ); \/* Opera 11.10+ *\/");
    document.writeln(" background-image:         linear-gradient( #ffffff , #cccccc );");
    document.writeln("}");
    document.writeln(".window .txtbtn:active {");
    document.writeln(" background-image: -webkit-gradient(linear, left top, left bottom, from( #cccccc ), to( #ffffff )); \/* Saf4+, Chrome *\/");
    document.writeln(" background-image: -webkit-linear-gradient( #cccccc , #ffffff ); \/* Chrome 10+, Saf5.1+ *\/");
    document.writeln(" background-image:    -moz-linear-gradient( #cccccc , #ffffff ); \/* FF3.6 *\/");
    document.writeln(" background-image:     -ms-linear-gradient( #cccccc , #ffffff ); \/* IE10 *\/");
    document.writeln(" background-image:      -o-linear-gradient( #cccccc , #ffffff ); \/* Opera 11.10+ *\/");
    document.writeln(" background-image:         linear-gradient( #cccccc , #ffffff );");
    document.writeln(" border: 1px solid #C9C9C9;");
    document.writeln(" border-top: 1px solid #B4B4B4;");
    document.writeln(" box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3) inset;");
    document.writeln("}");
    document.writeln("");
    document.writeln(".window .title .close {");
    document.writeln(" float:right;");
    document.writeln(" background-image: url(\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAABoAAAAaCAYAAACpSkzOAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACTSURBVEhL7dNtCoAgDAZgb60nsGN1tPLVCVNHmg76kQ8E1mwv+GG27cestQ4PvTZ69SFocBGpWa8+zHt\/Up+IN+MhgLlUmnIE1CpBQB2COZibfpnXhHFaIZkYph0SOeeK\/QJ8o7KOek84fkCWSBtfL+Ny2MPpCkPFMH6PWEhWhKncIyEk69VfiUuVhqJefds+YcwNbEwxGqGIFWYAAAAASUVORK5CYII=\");");
    document.writeln(" width:26px;");
    document.writeln(" height:26px;");
    document.writeln(" display:block; ");
    document.writeln("}");
    document.writeln("<\/style>");
    document.writeln("<div class=\"window\" id=\"windowcenter\">");
    document.writeln(" <div id=\"title\" class=\"title\">消息提醒<span class=\"close\" id=\"alertclose\"><\/span><\/div>");
    document.writeln(" <div class=\"content\">");
    document.writeln("  <div id=\"txt\"><\/div>");
    document.writeln("  <input type=\"button\" value=\"确定\" id=\"windowclosebutton\" name=\"确定\" class=\"txtbtn\"> ");
    document.writeln(" <\/div>");
    document.writeln("<\/div>");
    $(document).ready(function () { $("#windowclosebutton").click(function () { 
    $("#windowcenter").slideUp(500);
    }); 
    $("#alertclose").click(function () { 
    $("#windowcenter").slideUp(500);
    }); }); 
    function alert(title){ 
    //var windowHeight; 
    //var windowWidth; 
    //var popWidth;  
    //var popHeight; 
    //windowHeight=$(window).height(); 
    //windowWidth=$(window).width(); 
    //popHeight=$(".window").height(); 
    //popWidth=$(".window").width(); 
    //var popY=(windowHeight-popHeight)/2; 
    //var popX=(windowWidth-popWidth)/2; 
    //$("#windowcenter").css("top",popY).css("left",popX).slideToggle("slow"); 
    $("#windowcenter").slideToggle("slow"); 
    $("#txt").html(title);
    //$("#windowcenter").hide("slow"); 
    setTimeout('$("#windowcenter").slideUp(500)',8000);
      

  7.   

    function alert(title)你在那里调用的?
      

  8.   

    $("#save-btn").bind("click",
    function() {
    var btn  = $(this);
    var tel  = $("#tel").val();

    var wechaid = $("#wechaid").val();
    var winprize  = $("#winprize").val();
    var sncode  = $("#sncode").val();
    var lid  = $("#lid").val();
    //var RegPhone = /^([0-9]{11})?$/;
    //var falg;
    //falg = tel.value.search(RegPhone);
    if (!tel) {
    alert("请输入正确{pigcms:$lottery.renametel}");
    return
    }
    var submitData = {
    sncode  : sncode,
    tel  : tel,

    wechaid : wechaid,
    winprize:winprize,
    rid: {pigcms:$Coupon.rid},
    lid  : lid,
    action  : "add"
    };
    $.post('index.php?g=Wap&m=Coupon&a=add', submitData,
    function(data) {
    if (data.success == true) {
    alert(data.msg);
    window.location.href=location.href;
    //$("#zjl").hide("slow");
    return
    } else { 
    //alert('失败'+data);
    return
    }
    },"json")
    });$("#save-btnn").bind("click",
    function () {
    var submitData = {
    id: {pigcms:$lottery.id},
    rid: {pigcms:$Coupon.rid},
    parssword: $("#parssword").val()
    };
    $.post('index.php?g=Wap&m=Coupon&a=exchange', submitData,
    function (data) {
    if (data.success == true) {
    alert(data.msg);
    if (data.changed == true) {
    window.location.href = location.href;
    }
    return
    } else {alert(data.msg);}
    },
    "json")
    });
      

  9.   

    有报错误么。$record=$this->lottory_record_db->where(array('id'=>$rid))->find();   看看这条语句有没有出错呢。
      

  10.   

    没有哦,这条语句支掉,再把下面改成如下,还是弹不出来echo'{"success":1,"msg":"恭喜"}';
                exit;    
            }
      

  11.   

    if ($Lottery_pw['dpassword'] != trim($this->_post('parssword'))){
       echo'{"success":0,"msg":"密码不正确"}';exit;
       }else {
       $data['sendtime'] = time(); 
       $data['sendstutas'] = 1;
                     $data['dname'] = $Lottery_pw['dname'];
                     $data['dpassword'] = $Lottery_pw['dpassword'];
       $this->lottory_record_db->where(array('id'=> intval($_POST['rid'])))->save($data);
       echo'{"success":1,"msg":"领取成功","changed":1}';
       }
     }
     }昨晚又测试,发现密码错误的时候会提示,输入正确的时候不提示