一、判断某一个复选框是否被选中
二、从json文件中读取json格式的数据
//html、json、jsonp、script、text、xml
[color=darkred] dataType:必须有且只能为text或html,因为data是string
var obj = jQuery.parseJSON(data);将其转换为json对象
url为json文件的相对路径
[/color]
三、遍历json的list集合
$("#ch").is(":checked");
二、从json文件中读取json格式的数据
//html、json、jsonp、script、text、xml
[color=darkred] dataType:必须有且只能为text或html,因为data是string
var obj = jQuery.parseJSON(data);将其转换为json对象
url为json文件的相对路径
[/color]
$(document).ready(function(){
var $operation=$("#operation");
$operation.click(function(){
$.ajax({
url:"icon.json",
dataType: "text",
success:function(data){
//$.parseJSON();
var obj = jQuery.parseJSON(data);
alert(obj.list[0].type);
},
error:function(data){
alert(data);
}
});
});
});
三、遍历json的list集合
var obj = $.parseJSON(data);
$.each(obj.list,function(index,o){
if(index==0){
alert(o.type);
}
});