ERROR等待请求ajax完成

时间:2013-10-25 10:52:59

标签: javascript jquery ajax

我使用getjson来获取数据表单服务器。文件内容是获取图像以构建动态GUI的链接。 它有错误,这是getjson完成但图像链接仍然是空的。我想等待图像加载完成。因为我想在将它插入html之前反映图像。 这段代码。

//get json file from server
    $.getJSON(flicker).done(function( data ) {
            buildListMoviesChild(data, index,filename);
        });


//build content html

    function buildListMoviesChild(data) {


        for(var j = 0; j <= Math.floor((arrMovie.length -1)/numMovieInPage); j++) {
            var i = j*numMovieInPage; 
            var maxi = (1 + j)*numMovieInPage;
            var div_movie_page = document.createElement("div");
            div_movie_page.setAttribute("id", "movie_list_" + index + "_" + j);
            if(j!=0) {
                div_movie_page.setAttribute("style", "display: none");
            }

            for (;i<arrMovie.length; i++) {

                var img = document.createElement("img");
                img.setAttribute('src',  arrMovie[i].img);

          //create canvas to Reflect image. BUT I CAN'T DO THIS, IMG OBJECT EMPTY; PLEASE HELP ME WAIT TO IMAGE AVAILABLE
          Reflection(img, 40, 0.5 );

            }

            document.getElementById("movie_list_" + index).appendChild(img);

        }

    }


        function Reflection(img, reflHeight, opacity) {             
            console.log(img);
        console.log(reflHeight);
        console.log(opacity);
            var reflection, cntx, imageWidth = img.width, imageHeight = img.width, gradient, parent;
            alert('imageWidth  ' + imageWidth);
            alert('imageHeight  ' + imageHeight);
    // imageWidth   = 0; imageHeight  = 0 ALWAY;
            ...


    }]

请帮我解决这个问题。对不起,我的英语技能不好。

0 个答案:

没有答案