You don't have javascript enabled. Good luck! :(

欢迎页

Welcome to Ganace's Blog


欢迎您来到Ganace 的个人博客。

在茫茫互联网的海洋里能够遇见,实在是一份不小的幸运。

诚挚地向您问候一声:您好,朋友!

这里是属于Ganace个人的隐秘小空间,记录了工作学习中遇到的知识点与灵感,以及生活中的碎碎念与吐槽突如其来的中二病尬尬的文艺时间锻炼腹肌的时刻惊喜的小发现等等。

想要在自己的平淡无奇的人生长河中留下些什么,

或者只是为了拯救老人家岌岌可危的记忆力,

仅此而已。

来到此地,分享与你。

也期待与您的再次相遇!

Share with Me


有任何的分享或者建议与吐槽,都可以Email我:ganace@foxmail.com

欢迎您的来信!

【AJAX】关于AJAX使用的小笔记

  Jul 19, 2018     Ganace     Front-end-Foundation

jQuery
Ajax

这里是一篇Ganace记录的关于AJAX使用小笔记的文章。

这个需要用jQuery的相关对象来处理AJAX简化代码:

GET请求


发送一个GET请求,并返回一个JSON格式的数据:

var jqajax = $.ajax('/data.html', {
    dataType: 'json'
});

jQuery提供了get()方法:

var jqajax = $.get('/data.html', {
    name: 'Ganace',
    num: 1
});

POST请求


jQuery提供了post()方法:

var jqajax = $.post('/data.html', {
    name: 'Ganace',
    num: 1
},function(data){
	alert(data);
});

getJSON请求


jQuery提供了getJSON()方法:

var jqajax = $.getJSON('/data.html', {
    name: 'Ganace',
    num: 1
},function(data){
	// 此处data已经被解析为JSON对象
});

var jqajax = $.getJSON('/data.html', {
    name: 'Ganace',
    num: 1
}).done(function (data) {
    // 此处data已经被解析为JSON对象
});;