zoukankan      html  css  js  c++  java
  • Ajax

    前台:

       $.ajax({
       type: 'POST',
         url: '/admin/mall/category-add-edit.htm?ajax='+"ajax",
         data: "categoryId=" + categoryFormid+"&city="+city,
         success: function(msg){
          //alert(msg);
          if(msg==undefined || msg==null ||msg==""){
           return ;
          }
          var jo=eval('('+msg+')');
          //1百分比  2固定值
          $("#charge_type").val(jo.charge_type);
          if(jo.charge_type==1){
               document.getElementById('type1').style.display="";
               document.getElementById('type2').style.display="none";
              }
              if(jo.charge_type==2){
               document.getElementById('type1').style.display="none";
               document.getElementById('type2').style.display="";
              }
         }
      })

    后台:

          Long categoryId = ControllerUtils.getLongParameter(map, "categoryId", request);
          response.setContentType("text/html;charset=GBK");
          PrintWriter out = response.getWriter();
          JSONObject jsonO=new JSONObject();
          GoodsCategoryExt charge_type=extService.getExt(categoryId, "charge_type");
          GoodsCategoryExt fixTip=extService.getExt(categoryId, "fixTip");
          GoodsCategoryExt fee=extService.getExt(categoryId, "fee");
          jsonO.put("charge_type", charge_type.getExt_str());
          jsonO.put("fixTip", fixTip.getExt_str());
          jsonO.put("fee", fee.getExt_str());
          out.print(jsonO.toString());
          out.flush();
          out.close();
          return null;
    //这里必须return null; 否则会return mv等信息,对返回的信息进行干扰

    或者

              response.setCharacterEncoding("UTF-8");
              response.getWriter().write("exist");
              response.flushBuffer();
              return null;

    孔曰成仁,孟曰取义
  • 相关阅读:
    你不能忽视的HTML代码2精编篇
    C#中析构函数和命名空间的妙用
    值类型和引用类型及其它
    这些年我收集的GDI+代码2
    C#中超级好用的字符串
    Javascript的压缩优化
    Spring和hibernate多个数据源的事务管理
    android中Handler,Looper,Message的开发答疑
    Spring引用Tomcat的 JTA事务
    js禁止用户刷新页面
  • 原文地址:https://www.cnblogs.com/haorun/p/6021056.html
Copyright © 2011-2022 走看看