<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<button>获取教育信息</button>
<button>获取专长信息</button>
</body>
<script src="js/jquery-1.7.2.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
var ctrl = {
init:function(){
this.edu_click();
this.feat_click();
},
edu_click:function(){
$('button:first').click(function(){
model.edu_list(function(data){
view.show_edu(data)
})
})
},
feat_click:function(){
$('button:last').click(function(){
model.feat_list(function(data){
console.log(data)
})
})
}
};
ctrl.init();
var model = {
edu_list:function(callback){
$.ajax({
type:"get",
url:"http://127.0.0.1/1114/week2/04/Nickphp/index.php/house/api/edu_list",
success:function(txt){
var data = $.parseJSON(txt);
callback(data);
}
});
},
feat_list:function(callback){
$.ajax({
type:"get",
url:"http://127.0.0.1/1114/week2/04/Nickphp/index.php/house/api/feat_list",
success:function(txt){
var data = $.parseJSON(txt);
callback(data);
}
});
}
}
var view = {
show_edu:function(data){
var html = '';
$.each(data.result, function() {
html+='<b>'+this.title+'</b>';
});
$(document.body).append(html);
}
}
//view.show_edu({"result":[{"id":"1","title":"专长名"}]})
</script>
</html>