zoukankan      html  css  js  c++  java
  • js中的$.messager.alert不起作用,要仔细检查是否有拼写错误

    今天写前端,发现js中的$.messager.alert不起作用,我就在网上查。

    有的说是alert弹出框是阻断方式,执行完毕后面的closeWin()方法才会继续执行
    但是messag.alert弹出框不管你点不点确定,后面的方法都会执行,所以message.alert就会被后面的closeWin()方法覆盖掉;

    但我的原因并不是这个,报错之后,在浏览器中F12,发现其实是31行的count写成了counts,所以报错了,这一行并没有执行。

    反思:要仔细检查拼写错误才行啊,最好是采用一种命名规范,从始至终的遵守它。其次,要认真的对待报错信息,先读报错信息,再去网上找。

    代码如下:(不起作用的是第31行)

     1 $('#reportViewPreWithAuth').click(function(){
     2   var count=getRptCounts(reportid,$('#u_queryin').textbox('getValue'),$('#u_zdinfo').textbox('getValue'),$('#u_source').textbox('getValue'));
     3   if(verifyChannel()){
     4    //20200419权限校验
     5    $.ajax({
     6     type : 'get',
     7     url : owk.fn.url("/tjdpl/report/{}/{}.do", "report",$('#u_reportid').textbox('getValue')),
     8     dataType : 'json',
     9     success : function(result){
    10      window.alert("进入了ajax的success模块,result="+result);
    11      alert("result="+result);
    12      if(result=="yes"){
    13       window.alert("count:"+count);
    14       if(count<=500){
    15       window.alert("2222");
    16       $('#reportPreviewDialog').dialog({
    17           title: '报表预览',
    18              href:  '/tjdpl/html/report/reywPreviewWithAuth.html',
    19              iconCls:'',
    20              800,
    21              height:500,
    22        queryParams: {
    23             reportid : reportid,
    24             queryin : $('#u_queryin').textbox('getValue'),
    25             zdinfo : $('#u_zdinfo').textbox('getValue'),
    26             source : $('#u_source').textbox('getValue'),
    27        },
    28       }).dialog('open').dialog('center');
    29       }else{
    30        window.alert("messager应该起作用。")
    31        $.messager.alert("提示","报表记录有"+count+"条,大于500条,请下载后查看","warning");
    35        //alert("您当前没有权限,请申请对应报表/模型权限后查看!");
    36        return;
    37       }
    38      }else{
    39       $.messager.alert("提示","您没有此报表调阅权限,请在本页面点击"权限申请"按钮申请所需权限,如有任何问题请与报表技术负责人联系。","warning");
    40       //alert("您当前没有权限,请申请对应报表/模型权限后查看!");
    41       return;
    42      }
    43     }
    44    });
    45   }else{
    46    $.messager.alert("提示","访问渠道不正确,请使用正确的网络环境访问报表!","warning");
    47    //alert("访问渠道不正确,请使用正确的网络环境访问报表/模型");
    48    return;
    49   }
    50   
    51  });
  • 相关阅读:
    【HTTP】一、HTTP协议简介及其工作流程
    【总结】计算机网络常见问题
    【LeetCode】714、买卖股票的最佳时机含手续费
    【LeetCode】309、最佳买卖股票时机含冷冻期
    【LeetCode】188、买卖股票的最佳时机 IV
    【LeetCode】123、买卖股票的最佳时机 III
    【LeetCode】122、买卖股票的最佳时机 II
    【LeetCode】121、买卖股票的最佳时机
    windows搭建测试环境
    css 和常用快捷键
  • 原文地址:https://www.cnblogs.com/GritMVP/p/14361060.html
Copyright © 2011-2022 走看看