基本ajax交互
2019獨角獸企業重金招聘Python工程師標準>>>
HTML 和js
<script src="jquery-1.11.3.min.js"></script>
<button class="js-getJson">GO</button>
<script>
?? ?getJson();
?? ?function getJson() {
?? ??? ?$(".js-getJson").click(function(){
?? ??? ??? ?$.ajax({
?? ??? ??? ??? ?url : 'data.json',
?? ??? ??? ??? ?dataType : 'json',
?? ??? ??? ??? ?success : function(data) {
?? ??? ??? ??? ??? ?alert(data['name']);
?? ??? ??? ??? ??? ?$(".js-getJson").text("aaaa");
?? ??? ??? ??? ?},
?? ??? ??? ??? ?error : function(e) {
?? ??? ??? ??? ??? ?alert(e);
?? ??? ??? ??? ?}
?? ??? ??? ?});
?? ??? ?});
?? ?}
</script>
json
{
?? ?"name": "你是靚仔",
?? ?"data": "設計師",
?? ?"other": "前端"
}
效果
轉載于:https://my.oschina.net/parchments/blog/1576103
總結
- 上一篇: Tomcat的设置1——设置根目录
- 下一篇: 阿里云自定义监控tomcat进程数