解决方案 »
- 树各节点怎么保存到xml文件里
- Extjs 简单问题 但是没整出来 好心的人进来看看吧 在线等
- 再续昨天的话题,继续学习。。。
- 如何用js创建一个连接
- 终于找到了求老大们帮忙
- javascript定义的一个变量,其它的frame如何访问?
- 求一段图片跑马灯代码
- 求助,用javascript控制ie缓存的问题
- 谁知道“保留小数后几位”的函数是哪一个,谢谢。
- 获取子页面元素要点两次才能获取到,且修改子页面节点属性无效,到底哪里有问题望大腿们给瞧瞧?
- 可编辑div的小问题
- JS 动态创建DIV(IE8没问题)Google chrome提示:Uncaught TypeError: Illegal invocation
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
function createImages(arr){
var fragment=document.createDocumentFragment();
for(var i=0;i<arr.length;i++){
var img=new Image();
img.src=arr[i];
fragment.appendChild(img);
fragment.appendChild(document.createElement("br"));
}
document.body.appendChild(fragment);
}
function getWindowHeight(){
var de=document.documentElement;
return window.innerHeight||(de&&de.clientHeight)||document.body.clientHeight;
}
window.onscroll=function(){
var scrollTop=document.documentElement.scrollTop||document.body.scrollTop;
var scrollHeight=document.documentElement.scrollHeight||document.body.scrollHeight;
var windowHeight=getWindowHeight();
if(scrollTop+windowHeight==scrollHeight){
createImages(['460.gif'])
}
}
</script>
</head><body>
<img src="1.jpg"><br/>
<img src="2.jpg"><br/>
<img src="1.jpg"><br/>
</body>
</html>
类似这样试试
异步请求要靠ajax和后台页面的相互配合才能得到数据:ajax负责发出请求到后台页面===>>后台页面接收到请求后从数据库取出数据并将数据处理成一定的格式(常见如json,xml),然后把一定格式的数据传给ajax的回调函数===>>回调函数接收到数据后便进行读取处理。比如你想加载图片:
1.先用ajax发送请求,比如用get请求:www.xxx.com/img.php?amount=10;
2.请求发出后,后台img.php页面接受到请求并得到请求参数amount,然后就从数据库取出十条数据,并生成一定格式,如json:[
{
"imgSrc": "http://www.xxx.com/img/1.jpg",
"title": "标题1",
"describe": "描述1"
},
{
"imgSrc": "http://www.xxx.com/img/2.jpg",
"title": "标题2",
"describe": "描述2"
},
......//依次共十条数据
]3.img.php自动将json返给ajax的回调,回调函数就可以用数据中的imgSrc属性生成img插入到html中。