I have this script
我有这个脚本
say index.html
说index . html
<html>
<head>
<title>Ajax with jQuery Example</title>
<script type="text/JavaScript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
setInterval(function(){
$("#quote p").load("script.php");
}, 10000);
});</script>
<style type="text/css">
#wrapper {
width: 240px;
height: 80px;
margin: auto;
padding: 10px;
margin-top: 10px;
border: 1px solid black;
text-align: center;
}
</style>
</head>
<body>
<div id="wrapper">
<div id="quote"><p> </p></div>
</div>
</body>
</html>
script.php
script.php
<?php
echo "Hello how are you";?>
when loading index.html it is blank for 10 seconds and then it start functioning..how do I get rid of blank and how it can show instantly when browser loads??
当加载索引。它空了10秒钟,然后开始工作。如何消除空白,以及如何在浏览器加载时立即显示?
1 个解决方案
#1
4
Your setInterval()
call works as designed: It says "in 10 seconds and then every seconds, do this...."
你的setInterval()调用是设计:它说“在10秒,然后每一秒,做这个....”
Add a separate "load" call to do the initial filling:
添加一个单独的“load”调用来进行初始填充:
$(document).ready(function(){
$("#quote p").load("script.php"); // <--- Add this
setInterval(function(){
....
#1
4
Your setInterval()
call works as designed: It says "in 10 seconds and then every seconds, do this...."
你的setInterval()调用是设计:它说“在10秒,然后每一秒,做这个....”
Add a separate "load" call to do the initial filling:
添加一个单独的“load”调用来进行初始填充:
$(document).ready(function(){
$("#quote p").load("script.php"); // <--- Add this
setInterval(function(){
....