/*
*getJSON函数
*/
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<h1>People</h1>
<a href="file/helloAjax.js">hello</a>
<div id="text">xixi</div>
</body>
<script type="text/javascript" src="http://libs.baidu.com/jquery/2.0.0/jquery.js"></script>
<script type="text/javascript">
$(function(){
$("a").click(function() {
//使用getJSON方法 处理Ajax
var url = this.href;
var args={"date":new Date()};
$.getJSON(url,args,function(data){
var name = data.people.name;
var age = data.people.age;
var favorite = data.people.favorite;
$("#text").empty().append("<h2>name:"+name+" age:"+age+" favorite:"+favorite+"</h2>");
});
return false;
}
</script>
</html>
/**
* helloAjax.js
*/
{
"people":[{
"name":"li",
"age":11,
"favorite":"apple"
}]
}
问题描述:代码执行到getJSON处出错
qq_infinite
相关分类