开发者

want to preload an image for some time before getJson call

I am using a getJson call for drop downs. I want to hav开发者_如何学Pythone an image preloading effect for this ajax call. Can any one help me out with this...?? My code follows:

$.getJSON("myAction.do?method=fetchThruAJAX", {
    TypeNo: $("#Type").val(),
    ajax: 'true'
}, function(j) {
    var options = '<option selected value="-1">---Select---</option>';
    if (j != null) {
        $.each(j.Model, function(i, item) {
            options += '<option value="' + item.SeqNo + '">'
                + item.Name + '</option>';
        });
    }
    $("select#Model").html(options);
});


You can do that globally using the ajaxStart and ajaxStop events:

$("#yourEffectContainerID").ajaxStart(function() {
    $(this).fadeIn("fast");
}).ajaxStop(function() {
    $(this).fadeOut("fast");
});

That way, your effect container will be displayed during all AJAX requests (so that behavior is not limited to the specific getJSON() call you issue for your dropdown).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜