在一个action中返回了一个 List<String>型的变量list,
然后我将其转换为JSONArray类型,JSONArray array=JSONArray.fromObject(list);
请问在JQuery中,我该如何使用这个JSONArray类型的变量?
需要做什么转换吗?

解决方案 »

  1.   

    $.ajax({
       type: "POST",
       url: "some.php",
       dataType: "json",
       data: "name=John&location=Boston",
       success: function(data){
         //data为你action中传过来的json对象
       }
    });
      

  2.   

    最近我也在苦恼jQuery ajax 提交给asp然后返json的问题,怎么都不行
      

  3.   

    假设你的list里面都是字符串,json为:
    ["111","222"]那JS可以这么调用:$.ajax({
      type: "POST",
      url: ".....",
      dataType: "json",
      success: function(data){
      //
    alert(data[0]);
      }
    });假设你的list里面都是其他对象,json为:
    [{"aa":"111"}]
    那JS可以这么调用:$.ajax({
      type: "POST",
      url: ".....",
      dataType: "json",
      success: function(data){
      //
    alert(data[0].aa);
      }
    });