AJAX后台Map转化为json返回

    /**定时查询报送记录数据,json格式数据显示在页面**/
    public void timeoutCheckSendDataStatus(){
        String applyId = ServletActionContext.getRequest().getParameter("applyId");
        Map params = new HashMap();
        params.put("permitId", applyId);
        Map rMap = this.service.findStatus(params);

        net.sf.json.JSONObject rJson = net.sf.json.JSONObject.fromObject(rMap);
        ajaxResult(rJson.toString(), "application/json");
    }

    public void ajaxResult(String content, String type) {  
        try {  
            HttpServletResponse response = getResponse();  
            response.setContentType(type + ";charset=UTF-8");  
            response.setHeader("Pragma", "No-cache");  
            response.setHeader("Cache-Control", "no-cache");  
            response.setDateHeader("Expires", 0);  
            response.getWriter().write(content);  
            response.getWriter().flush();  
        } catch (IOException e) {  
            e.printStackTrace();  
        }  
    }  

页面处理,也有对下拉列表进行操作

$.post("<%=request.getContextPath()%>/ac/tAction.action",{applyId:pid},
                function(results){
                    //console.log(results.sendProgressType);
                    $('#sendNodeType').val(results.sendNodeType);
                    $('#sendProgressType').val(results.sendProgressType);

                    $("#resultsSendData").css("color","red");
                    $("#resultsSendData").html(results.sendDataStatus);

                    $("#resultsSendDataErrorInfo").css("color","red");
                    $("#resultsSendDataErrorInfo").html(results.sendDataErrorInfo);

                    var selOpt = $("#completeResult option");
                    selOpt.remove();

                    var selObj = $("#completeResult");
                    var value="1";
                    var text="出证办结";

                    if(results.sendProgressType=='4'){
                        value="2";
                        text="退回办结";
                        selObj.append("+text+"");
                    }else{
                        selObj.append("+text+"");

                        if(results.sendNodeType==null||results.sendNodeType==''||results.sendNodeType=='undefined'||results.sendNodeType==undefined){
                            value="2";
                            text="退回办结";
                            selObj.append("+text+"");
                        }
                    }

                    setTimeout("cAjaxress()", 5000);
            });

你可能感兴趣的:(JAVASCRIPT)