0

我有这样的代码

function loadAjaxData(code) {
$.ajax({
                type : 'POST',
                url : 'loadData.html',
                dataType : 'json',
                data : {
                    "limited_num" : limited_num,
                    "search_bunrui_code" : code,
                    "orderType" : orderType,
                    "search_base_date_from" : search_base_date_from,
                    "search_base_date_to" : search_base_date_to,
                    "compare_date_from" : compare_date_from,
                    "compare_date_to" : compare_date_to
},
success : function(data) {
},
});

据我所知,上面的数据是将参数传递给服务器。并在服务器中为我返回 Json 的数组对象问题是我如何才能成功获得该数组谢谢您的帮助

这是服务器中的代码

 @Result(name="loadData",type="json"),

public ArrayList<OrderDeliverAmoutReturnList> returnList;

@Action(value="loadData", results = {
                @Result(name="loadData", type="json", params ={"includeProperties", "returnList"})
            })
    public String loadData() throws Exception{
        OrderDeliverAmoutSearchTO searchTo=this.setCondition();
        returnList=bunruiSummaryService.getBunruiSyouhinShopDayList(searchTo);
        total=this.caculateTotal();

        return "loadData";
    }
4

3 回答 3

1

如果您从服务器发送带有 json 类型标头的 json 数据,那么您可以直接在成功方法内的数据变量中获取 json 对象。

对于您可以使用的服务器的 text/html 标头。

var jsonObject = $.parseJSON(data)

在 jsonObject 中获取 json 或数组。

于 2013-06-06T08:46:28.790 回答
0

它在data成功回调的变量中:function(data) { }

于 2013-06-06T08:45:22.523 回答
0

这里,'data' 本身就是 json 对象。如果它是数组,你可以像这样使用它

success : function(data) {
  for(int i=0;i< data.length;i++){
    alert(data[i]);//use it
  }
}
于 2013-06-06T08:46:00.820 回答