how to loop through json array in jquery?

前端 未结 8 560
温柔的废话
温柔的废话 2020-12-09 09:03

I have a php page from which I get response in json:

[{\'com\':\'something\'},{\'com\':\'some other thing\'}]

I want to loop it and append

8条回答
  •  伪装坚强ぢ
    2020-12-09 09:25

    Your array has default keys(0,1) which store object {'com':'some thing'} use:

    var obj = jQuery.parseJSON(response);
    $.each(obj, function(key,value) {
      alert(value.com);
    }); 
    

提交回复
热议问题