ajax 局部刷新,返回json字符串

JSP:

$.ajax({

        target:"#myGiftTbody",
        type: "POST", 
        url: "queryGift.html",
        dataType: "json",
        success:function(data) {
            var tr;
            var td;
            var jsonObj = eval("("+data+")");
            if(jsonObj == null) {
                return error;
            }
            for (var i = 0; i < jsonObj.length; i++) {
                var mySecurityReportRecord = new Array();
                mySecurityReportRecord.push(jsonObj[i].name + "【兑换数:"+jsonObj[i].orderItemCount+"】");
                mySecurityReportRecord.push(jsonObj[i].createdDate);
                mySecurityReportRecord.push(jsonObj[i].receiverAddressDetail);
                mySecurityReportRecord.push(jsonObj[i].receiverName);
                mySecurityReportRecord.push(jsonObj[i].receiverMobile);
                 if ('COMMITED' == jsonObj[i].orderStatus) {
                     jsonObj[i].orderStatus = '已提交';
                 }else if ('CANCELED' == jsonObj[i].orderStatus) {
                     jsonObj[i].orderStatus = '已取消';
                 } else if ('CONFIRMED' == jsonObj[i].orderStatus) {
                     jsonObj[i].orderStatus = '已确认';
                 } else if ('SHIPMENT' == jsonObj[i].orderStatus) {
                     jsonObj[i].orderStatus = '发货中';
                 } else if ('FINISHED' == jsonObj[i].orderStatus) {
                     jsonObj[i].orderStatus = '订单完成';
                 }
                mySecurityReportRecord.push(jsonObj[i].orderStatus);
                mySecurityReportRecord.push(jsonObj[i].handleDescription);
                leakTableValues.push(mySecurityReportRecord);
            }
    
            for(var i=0;i                 tr = document.createElement("tr");
                for(var j=0;j                     td = document.createElement("td");
                    td.innerHTML = ""+ leakTableValues[i][j] + "";
                    tr.appendChild(td);
                }
                document.getElementById("myGiftTbody").appendChild(tr);
                $("#test").val(1);
            }
        }

    });


JAVA:

将结果转化为json字符串:

JSONArray json = JSONArray.fromObject(list);
            this.setResult(json.toString());

ACTION配置:


           
                result
           

       

你可能感兴趣的:(javascript,javacore)