Created
October 24, 2012 16:36
-
-
Save zzuhan/3947191 to your computer and use it in GitHub Desktop.
simple ajax
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('#loading').ajaxStart(function () { | |
$(this).show(); | |
}); | |
$('#loading').ajaxStop(function () { | |
$(this).hide(); | |
}); | |
$('#send').click(function () { | |
// 我们先传递给其 callback 的name 然后其返回一个函数的调用,数据在参数中 | |
// jQuery18206735994638875127_1350706129349(data); | |
// 返回来的是对回调函数的执行,传入了需要的参数 | |
$.getJSON('http://api.flickr.com/services/feeds/photos_public.gne?tags=car&tagmode=any&format=json&jsoncallback=?', function (data) { | |
$('#resText').empty(); | |
$.each(data.items, function (i, item) { | |
$('<img class="para"/>') | |
.attr('src', item.media.m) | |
.appendTo($('#resText')); | |
if (i==3) { return false; } | |
}); | |
}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="loading">加载中...</div> | |
<button id="send">发送</button> | |
<div id="resText"> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment