我有几个包含滚动 html 字幕的 wordpress 页面。加载页面时,使用 ajax 调用从 sql db 获取内容,然后填充选框。一切正常,但是当您导航到页面时,选取框到达顶部,然后重新开始。如果您刷新页面,一切都会按预期进行。只是当页面第一次导航到问题发生的地方时。
有什么建议吗?这几乎就像选取框在所有内容被检索并插入标签之前开始?
WordPress的html:
<script type='text/javascript' src='/scripts/dialog/js/jquery-ui-1.8.18.custom.min.js'> </script>
<script type='text/javascript' src='/scripts/dialog/js/jquery-1.7.1.min.js'></script>
<script type='text/javascript' src='/scripts/dialog/popupDialog.js'></script>
<div id="emptyMarquee" class="emptyMarquee-tall"></div>
<marquee class="marquee-tall" name="Compliance" direction="up" behavior="scroll" scrollamount="3">
<center>
</center>
</marquee>
popupDialog.js
$(function(){
//hide the empty marquee and the marquee wrapper
$("#emptyMarquee").hide();
$("#marquee").hide();
//get projects from server
var serviceArea = $("#marquee").attr("name");
var query = "serviceArea=" + serviceArea;
$.ajax({
type: "GET",
url: "/scripts/dialog/getMarqueeData.php",
data: query,
dataType: "json",
success: function(returnData){
if (!(returnData.aaData[0] == "none")){//atleast 1 project returned from db
$("#emptyMarquee").hide();
//create marquee element
$("#marquee").html("<marquee class='marquee-tall' direction='up' behavior='scroll' scrollamount='3'><center></center></marquee>");
var projArr = [];
for (var i = 0; i < returnData.aaData.length; i++) {
//returnData.aaData[i][0] - name
//returnData.aaData[i][1] - description
projArr.push("<strong>" + returnData.aaData[i][0] + "</strong> - " + returnData.aaData[i][1] + "</br></br>");
};
$.each(projArr,function(index, value){
$("marquee center").append(value);
})
$("#marquee").show();
}
else{//no projects returned from db, show emptyMarquee div, fill with msg
$("#marquee").hide();
$("#emptyMarquee").html("Please check back soon for updated " + serviceArea + " projects.");
$("#emptyMarquee").show();
}
}
})
});