Reading JSON string in Jquery

后端 未结 2 1429
难免孤独
难免孤独 2021-01-22 14:52

When i try to read a JSON string like below it goes to endless loop.



        
2条回答
  •  伪装坚强ぢ
    2021-01-22 15:16

    $("#Button1").click(function() {
      var json = $.parseJSON("[{'City':'Lucknow','ID':'1'},{'City':'Mumbai','ID':'2'}]");
      $.each(json, function() {
        alert(this['City']);
    });
    

    It's better to use json2.js from: http://www.json.org/js.html

提交回复
热议问题