weixin_33743661 2015-03-03 14:33 采纳率: 0%
浏览 3

用jQuery迭代地图

will i'm using spring mvc with ajax for my application , my issue is that i don't know how i can iterate a map that i sent from spring controller.

Controller code

                    ObjectMapper mapper = new ObjectMapper();
                    String json = "";
                    try {

                        json = mapper.writeValueAsString(ser.StatistiquesCompte());
                    } catch (Exception e) {
                        System.out.println("erreur ici");
                    }

                     return json;

and my ajax code look like that :

            $.ajax({
                url : 'Stats',
                success : function(data) {
                    alert(data);
                }
            });

my result is like that : {"Key":10,"Key1",30} how i am supposed to iterate this map.

  • 写回答

3条回答 默认 最新

  • weixin_33711641 2015-03-03 14:37
    关注

    Itreate your response data like this

    $.ajax({
        url : 'Stats',
        success : function(data) {
             $.each(data , function( key, value ) {
                 console.log( key + ": " + value ); // Key : 10
             });
        }
    });
    
    评论

报告相同问题?