簡體   English   中英

自動刷新DIV,無需PHP

[英]Autorefresh DIV, No PHP

我想在此頁面上自動刷新div: http : //americanart.si.edu/index_newsplash3r.cfm (“探索的地方”區域)。 現在,當您重新加載頁面時,我們可以隨意顯示3種不同的圖像和文本。 我希望這些元素能夠自動更改,而無需重新加載頁面。

該頁面在Coldfusion 9中完成。大多數AJAX自動刷新代碼均假定您使用的是PHP。

有沒有人鏈接到無需PHP即可執行此操作的代碼? 我認為沒有必要使用Coldfusion代碼。

謝謝。

您可以在服務器端設置Ajax調用以獲取照片路徑和文本。 這樣的事情。

    $(function(){
        function FillDivAtRandom(current){
        setTimeout(function(){

            //pass the current place to explore id to the server so you don't get the same back, if none then return anyone.

            $.post("http://americanart.si.edu/Request/PlacesToExploreNext", current, function(data){

//fill the div with new data return from server
//you don't seem to have an ID on that div or elements so put one on it first then use it as a selector 

                //set the image
                $('#placestoexplore_image').attr('src', data.image);
                //set the text
                $('#placestoexplore_description').html(data.description);
            });

            //call the function again
            FillDivAtRandom(current);

        }, 10000);

        }
    }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM