开发者

Jquery loading effect

in my index page, i've code like this :

function cek(){
        $container = $("#containermsg").notify();

        $.ajax({
            url: 'http://192.168.2.45:49/KP/UploadManag开发者_运维知识库er/filemover',
            cache: false,
            success: function(datas){
                $("#filemovernotif").html(datas);
            }
        });
        var waktucek = setTimeout("cek()",900000); //satuan ms
    }

i want to run the url every 90000 ms, but it not run well, because this code will run every time page loaded/refreshing.

i also want to ask about page loading effect for this code. The objective of url:'http://192.168.2.45:49/KP/UploadManager/filemover' is to uploading the content of many large file into database, so it run about 1 minutes or more. How can i show loading progress on the page while filemover doing uploading progress. i'm sorry for my bad english. Thank's in advance.


Edit: As far as I know timer always run until it is cleared out, so declaring it once is enough.

Restructure your code and take waktucek variable outside of the function. And about loading, a quick idea is: after ajax function call show a loading image anywhere and inside success(when upload is complete) just remove the image:

function cek(){
        $container = $("#containermsg").notify();

        $.ajax({
            url: 'http://192.168.2.45:49/KP/UploadManager/filemover',
            cache: false,
            success: function(datas){
        // Remove the src
        $("#statusDivImg").src(null);

        $("#filemovernotif").html(datas);
            }
        });

       // Show loading image
       $("#statusDivImg").src("/path/to/loading/image");
    }

// Timer set
var waktucek = setTimeout("cek()",900000); //satuan ms
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜