开发者

severe OPERA problem loading google image search json with jquery..(

my code works fine with IE8, Chrome, FireFox, but DOESN't in last Opera 11.5, 11.51

 <script>

$.ajax({
    url:"https://ajax.googleapis.com/ajax/services/search/images?v=1.0&q=barack%20obama&key=ABQIAAAA0WIba2EsveoBgNmpFF4VPBT_f2PMeCqK40xCWP-HTF5Ln8EjvhRvRnHj8jasieBYBypbUK53aU5vOA&mgsz=medium",
    dataType:"jsonp",
    cache: false,
    success: function(data){

    for (var i = 0; i < data.responseData.results.length; i++){

     $('#imago').append('<img src="' + data.responseData.results[i].tbUrl + '">' + 开发者_JAVA技巧'<br>');

    }



    }

});


</script>

<div id="imago"></div>

noticed paradox: if I add a line, alerting data.responseData.results[i].tbUrl before appending received tbUrl images, it becomes working in Opera too...

here's example: http://saitostroi.by/im.php


You need to move the DIV you want to insert results into above the script that does the Ajax query. The reason is that Opera doesn't continue parsing (and thus doesn't see the DIV) when jQuery appends a script to the document, until that script is done loading.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜