zoukankan      html  css  js  c++  java
  • struts1 下的 jquery ajax 记录

    JS 代码

    function checkInternalTransaction(actionType,idNum) {
        var url = "/sales/checkInternalTransaction.do";
        var checkMsg;
       $.ajax({
           type : 'post',
           dataType : "text",
           url : url,      
           data : "actionType="+actionType+"&idNum="+idNum,
           cache : false,
           async : false,
           success : function(msg) {
               checkMsg = msg;  //msg 即前台返回的值,默认字符串类型,后台返回了 true 前台接收到的是字符串 "true"
           }
       })
       return  checkMsg;
    }

    struts1 配置

    <action path="/checkInternalTransaction" type="com.sinosoft.sales.ui.control.facade.UIInternalTransactionFacade"
        name="fm" scope="request">
    </action>

    后台代码

    public class UIInternalTransactionFacade  extends Action{
        @Override
        public ActionForward execute(ActionMapping mapping, ActionForm form,
                HttpServletRequest request, HttpServletResponse response)
                throws Exception {
            DBInternalTransaction DBInternalTransaction = new DBInternalTransaction();
            boolean resultBoolean = true;
            String actionType = request.getParameter("actionType");
            String idNum = request.getParameter("idNum");
            if(null==idNum||"".equals(idNum)){
                response.getWriter().print(true); //直接调用该方法想前台返回值
                return null;
            }
            if(actionType.equals("IDV")){
                int count = DBInternalTransaction.checkIdvIdNum(idNum);
                resultBoolean = count==0?true:false; //未查询到数据,则校验通过,查询到数据则在页面弹出提示。
            }
            if(actionType.equals("UNIT")){
                int count = DBInternalTransaction.checkUnitIdNum(idNum);
                resultBoolean = count==0?true:false; //未查询到数据,则校验通过,查询到数据则在页面弹出提示。
            }
            response.getWriter().print(resultBoolean);
            return null; //不需要跳转,返回null
        }
    }
  • 相关阅读:
    build tools
    文档系统总结
    各进制及其转换详解
    JQuery 函数执行顺序
    计算页面宽高的函数
    Linq中的多表左联,详细语句
    css设置滚动条颜色与样式以及如何去掉与隐藏滚动条
    基于JQUERY写的 LISTBOX 选择器
    js/jquery 实时监听输入框值变化的完美方案:oninput & onpropertychange
    JQuery select控件的相关操作
  • 原文地址:https://www.cnblogs.com/heiniao/p/6425528.html
Copyright © 2011-2022 走看看