求具體代碼 還有在客戶端 怎麼解析。感謝

解决方案 »

  1.   


    List<Map<String, String>> list = new ArrayList<Map<String, String>>();
    int total = dpDirectoryService.getDpDirectoryCount(dpDirectory);
    list = dpDirectoryService.getDpDirectoryInfo(dpDirectory);
    PrintWriter write = response.getWriter();
    JSONObject o = new JSONObject();
    o.put("total", total);
    o.put("rows", list);
    write.write(o.toString()); write.flush();
    write.close();
    o.clear();服务端直接用response.getWriter();输出JSON串。
    客户端请求:
    $.ajax({
       type: "get",
       url: url,
       async: false,
       success: function(msg){   
                                               alert(msg);//这里的msg就是JSON串了  
      }
    });
      

  2.   

    服务器端你用什么语言,java你可以用fastjson直接解析一个对象,返回JSON字符串,然后用response对象
    输出他。
    php直接用echo json_encode(array('name'=>'吴红军'));这样输出返回给客户端jquery ajax这样获取:$.ajax({
        url:'服务器端地址',
        type:'GET',//以GET方式请求,
        data:{id:1},//你需要传递的数据,我这里id:1随便写的
        dataType:'json',//如果放回json,这里必须明确表示为json,否则他不理你的,
        success:function(rs){
            rs.xxx//xxx就是你的数据,干你想干的事情都在这里。
        }
    });
      

  3.   

    服務器我用sturts2.0 進行數據推送
      

  4.   

    struts2你先要获取response对象,然后response 输出那个falstjson转换后的字符串就行了。
    具体可以加我:54963779
      

  5.   


    import net.sf.json.JSONObject; 
    這包已經加進來了啊!
      

  6.   

    如果是
    $.ajax({
        url:'http://192.168.1.1/123.asp',
        type:'GET',//以GET方式请求,
        data:{id:1},//你需要传递的数据,我这里id:1随便写的
        dataType:'json',//如果放回json,这里必须明确表示为json,否则他不理你的,
        success:function(rs){
            rs.xxx//xxx就是你的数据,干你想干的事情都在这里。
        }
    });那么123.asp的代码应乍个写?
      

  7.   

    如果是
    $.ajax({
        url:'http://192.168.1.1/123.asp',
        type:'GET',//以GET方式请求,
        data:{id:1},//你需要传递的数据,我这里id:1随便写的
        dataType:'json',//如果放回json,这里必须明确表示为json,否则他不理你的,
        success:function(rs){
            rs.xxx//xxx就是你的数据,干你想干的事情都在这里。
        }
    });那么123.asp的代码应乍个写?