发布于 1970-01-01 08:00
  • 2 个回答
    • 都用ajax了,自己拼装data发过去啰,还拘泥于一个form干嘛?

      2022-12-01 11:05 回答
    • 用JQuery和Ajax了那就用这样的代码吧
      `
      $('#btn-confirm-login').on('click', function(){

      $.ajax({
          beforeSend:function(){
                  if($('#input-account').val().length == 0) {
                       ui.error("请输入帐号");
                      $('#input-account').focus();
                      return false;
                  }
                  if($('#input-password').val().length == 0) {
                       ui.error("请输入密码");
                      $('#pinput-password').focus();
                      return false;
                  }
                  return true;
              },
          dataType:"json",
          data:{"user":user,"pwsd":pwsd},
           success: function(i){
                  $('#error-msg-tip').html('<p>'+i.info+'</p>').show();
                  if(i.status == 1){
                      if(i.data == 0){
                          window.location.href = U('public/Index/index');  
                      }else{
                          window.location.href = i.data;            
                      }
                  }else if(i.status == 2){
                      var membs = i.data;

      // console.log(membs);

                      var $con = $('#select-sub-acc');
                      $con.empty();
                      $.each(membs, function(i, e){
                          var $btn = $("<button></button>");
                          $btn.text(e.uname).data("acc", e.worket).data('uid', e.uid);
                          $btn.on('click', function(){
                              //var worket = $(this).data('acc');
                              var uid = $(this).data('uid');
                              $('#hidden-uid').val(uid);
                              //$('#input-account').val(worket);
                              $('#btn-confirm-login').trigger('click');
                          });
                          $con.append($btn);
                      });
      
                      var $dialog = $('#select-sub-acc').dialog({
                          autoOpen: false,
                          height: 200,
                          width: 300,
                          modal: true,
                          title:"请确定一个帐号"
                      });
                      $dialog.dialog('open');
                  }
              }  
      });

      `

      2022-12-01 11:05 回答
    撰写答案
    今天,你开发时遇到什么问题呢?
    立即提问
    PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
    Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有