最小延时问题
好想html表对两个延时操作有规定:
setTimeout 为4ms
setInterval 为10ms
可参考这里
发送http请求
网上看的代码,写得非常简洁,同步请求:
function httpGet(theUrl)
{
var xmlHttp = new XMLHttpRequest();
xmlHttp.open( "GET", theUrl, false ); // false for synchronous request
xmlHttp.send( null );
return xmlHttp.responseText;
}
据说同步请求并不推荐,还是用异步的:
function httpGetAsync(theUrl, callback)
{
var xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState == 4 && xmlHttp.status == 200)
callback(xmlHttp.responseText);
}
xmlHttp.open("GET", theUrl, true);// true for asynchronous
xmlHttp.send(null);
}
本文探讨了JavaScript中setTimeout与setInterval的最小延时限制,并提供了实现HTTP请求的同步与异步方法。了解这些基本概念有助于更好地进行网页编程。
1139

被折叠的 条评论
为什么被折叠?



