function ajax(url, fnSucc, fnFaild)
{
//1.创建Ajax对象
if(window.XMLHttpRequest)
{
var oAjax=new XMLHttpRequest();
}
else
{
var oAjax=new ActiveXObject("Microsoft.XMLHTTP");
}
//2.连接服务器(打开和服务器的连接)
oAjax.open('GET', url, true);
//3.发送
oAjax.send();
//4.接收
oAjax.onreadystatechange=function ()
{
if(oAjax.readyState==4)
{
if(oAjax.status==200)
{
//alert('成功了:'+oAjax.responseText);
fnSucc(oAjax.responseText);
}
else
{
//alert('失败了');
if(fnFaild)
{
fnFaild();
}
}
}
};
}
[{a: 5, b: 7}, {a: 8, b: 12}]
arr[0] ------[object Object]
arr[0].a------5
[{user: 'blue', pass: '123456'},{user: '张三', pass: '654321'},{user: '李四', pass: '789456'},{user: '王五', pass: '7777'}]
aLi.innerHTML="user:<strong>"+data[i].user+"</strong>;pass:<span>"+data[i].pass+"</span>";
var LangShen = {"Name":"Langshen","AGE":"28"};
var LangShen = {
Name = function(){
return "LangShen";
},
Age = function(){
return "28";
}
}
var LangShen = { "Name":"Langshen",
"MyWife":[ "LuLu","26" ],
"MySon":[{"Name":"Son1"},{"Name":"Son2"},{"Name":"Son3"}]
}
调用起来,也是一层一层访问,对象的属性用.(点)叠加,数组用 [下标] 来访问。 如:alert( LangShen.MySon[1].Name ) ;
eval函数会评估一个给定的含有JavaScript代码的字符串,并且试图去执行包含在字符串里的表达式或者一系列的合法的JavaScript语句。eval函数将把最后一个表达式或者语句所包含的值或引用作为返回值。