1 回答

TA贡献1830条经验 获得超3个赞
您可能需要更改 data 的变量类型才能循环遍历它。您可以通过console.log(typeof data)检查变量的类型。以下是您的问题的可能解决方案,看看这是否对您有帮助。
success:function(data){
console.log(typeof data); // should be string
data = jQuery.parseJSON(data);
console.log(typeof data); // should be object
$.each(data['hasil'], function(key, val){
$.each(val, function(subkey, subval){
console.log(subkey);
console.log(subval);
// all values are assigned to the elements with the same id as their keys(as your code suggests)
$('#' + subkey).val('<value="' + subval + '">');
});
});
}
- 1 回答
- 0 关注
- 116 浏览
添加回答
举报