AJAX数据处理方式

1.HTML的处理方式(responseText)
2.XML的处理方式(responseXML及DOM)
优点:格式固定,容易扩展数据,层析清晰
缺点:节点的获取(有问题)
所以解析XML一般用服务器语言(DOM)
3.JSON(eval函数格式化及responseJSON)
JSON:利用js的对象来表示的数据(字符串)
js字面量:
1.对象字面量:
{
stu1:{name:"张三",sex:"男",birthday:{year:1990,month:12,day:12}},
stu2:{name:"李四",sex:"男",birthday:{year:1990,month:12,day:12}},
stu3:{name:"王五",sex:"男",birthday:{year:1990,month:12,day:12}},
stu4:{name:"赵六",sex:"男",birthday:{year:1990,month:12,day:12}}
}
{属性名:属性值,...}
优点:访问简单,易获取(通过eval转换格式)
缺点:格式不固定,没有规则(写json的时候格外注意)
2.数组字面量:[{属性:值},{值},{...}]
[
{name:"张三",sex:"男",birthday:{year:1990,month:12,day:12}},
{name:"李四",sex:"男",birthday:{year:1990,month:12,day:12}},
{name:"王五",sex:"男",birthday:{year:1990,month:12,day:12}},
{name:"赵六",sex:"男",birthday:{year:1990,month:12,day:12}}
]

你可能感兴趣的:(Ajax,json,xml,服务器,扩展,语言)