收藏ajax 常用功能代码!!

zoujp_xyz 2008-11-30 10:44:08
收藏ajax 常用功能代码!!
...全文
356 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
zjzb0409 2008-12-08
  • 打赏
  • 举报
回复
up
xingchen228 2008-12-08
  • 打赏
  • 举报
回复
mark
gundamtw 2008-12-07
  • 打赏
  • 举报
回复
mark 肯定是要各位高手 写一些常用的LZ要收藏
mgqy 2008-12-06
  • 打赏
  • 举报
回复
还不如花一周时间学习一下AJAX框架呢,想轻量级的jQuery、prototyp、ext等等框架都很好用,我认为jquery不叫好一下,因为压缩后的代码只有30k而且有N多的插件可供使用
ruanchao 2008-12-03
  • 打赏
  • 举报
回复
大概是让我们提供AJAX代码,他收藏起来吧?

Yes or No?
comeonbabye 2008-12-02
  • 打赏
  • 举报
回复
新手...哈哈
空心兜兜 2008-12-01
  • 打赏
  • 举报
回复
MARK

yougucao379548695 2008-12-01
  • 打赏
  • 举报
回复
是啊。我也没看到啊!
lynn_9527 2008-12-01
  • 打赏
  • 举报
回复
没多少技术含量
西安风影 2008-12-01
  • 打赏
  • 举报
回复
Ajax缓存的问题解决方法.txt
方法一:
xmlHttp.open("GET", "default.aspx?param="+Math.random(), true);
或者
xmlHttp.open("GET", "default.aspx?param="+new Date().getTime(), true);
方法二:
xmlHttp.open("GET", "default.aspx", true);
xmlHttp.setRequestHeader("If-Modified-Since","0");
xmlHttp.send(null);
西安风影 2008-12-01
  • 打赏
  • 举报
回复
Ajax实现无刷新二级级联
<html>
<head>
<script>
var xmlHttp;
function createXMLHttpRequest()
{
if(window.ActiveXObject)
{
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if(window.XMLHttpRequest)
{
xmlHttp = new XMLHttpRequest();
}
}
function startRequest(province)
{
createXMLHttpRequest();
try
{
xmlHttp.onreadystatechange = function(){handleStateChange(province);}
xmlHttp.open("GET", "data.xml", true);
xmlHttp.send(null);
}
catch(exception)
{
alert("xmlHttp Fail");
}
}
function handleStateChange(province)
{
if(xmlHttp.readyState == 4)
{
if (xmlHttp.status == 200 || xmlHttp.status == 0)
{
var root= xmlHttp.responseXML.documentElement;
try
{
var citySelect=document.getElementById("city");
citySelect.options.length=0;
var province=root.getElementsByTagName(province)[0];
var citys=province.getElementsByTagName("city");
for(var i=0; i<citys.length; i++)
{
var city=citys[i];
var cityName=city.getElementsByTagName("name")[0].firstChild.nodeValue;
var cityValue=city.getElementsByTagName("id")[0].firstChild.nodeValue;
var option=new Option(cityName, cityValue);
citySelect.options.add(option);
}
}
catch(exception)
{
alert("The node is not exist");
}
}
}
}
function DisplayCity(province)
{
if(province == "")
{
var citySelect=document.getElementById("city");
citySelect.options.length=0;
return;
}
else
{
startRequest(province);
}
}
</script>
</head>
<body onload="startRequest('Shanxi');">
<select id= "province" onchange="DisplayCity(this.options[this.selectedIndex].text);" align="center" style="width:100px">
<option value="0"></option>
<option value="1" selected="selected">Shanxi</option>
<option value="2">Guangdong</option>
</select>
<br>
<select id= "city" align="center" style="width:100px">
</select>
</body>
</html>

xml:
<?xml version="1.0" encoding="GB2312"?>
<root>
<Shanxi>
<city>
<name>Xian</name>
<id>1</id>
</city>
<city>
<name>Xianyang</name>
<id>2</id>
</city>
<city>
<name>Baoji</name>
<id>3</id>
</city>
<city>
<name>Weinan</name>
<id>4</id>
</city>
<city>
<name>Hanzhong</name>
<id>5</id>
</city>
</Shanxi>
<Guangdong>
<city>
<name>Shenzhen</name>
<id>1</id>
</city>
<city>
<name>Dongguan</name>
<id>2</id>
</city>
<city>
<name>Zhongshan</name>
<id>3</id>
</city>
<city>
<name>Huizhou</name>
<id>4</id>
</city>
<city>
<name>Foshan</name>
<id>5</id>
</city>
</Guangdong>
</root>
lunawzh 2008-11-30
  • 打赏
  • 举报
回复
[Quote=引用楼主 zoujp_xyz 的帖子:]
收藏ajax 常用功能代码!!
[/Quote]

在那呢.没看到
peacock 2008-11-30
  • 打赏
  • 举报
回复
最基础的就是这个,其它的应用都可以从此扩充

function initAjax()
{
  var ajax = false;
  try {
   ajax = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (e) {
try {
    ajax = new ActiveXObject("Microsoft.XMLHTTP");
   } catch (E) {
    ajax = false;
   }
  }
  if (! ajax && typeof XMLHttpRequest != 'undefined') {
   ajax = new XMLHttpRequest();
  }
  return ajax;
}

function getAjax(httpurl, requests, div)
{
if (typeof(httpurl, requests, div) == 'undefined')
{
  return false;
}
var url = httpurl + requests;
var show = document.getElementById(div);
var ajax = initAjax();
ajax.open("GET", url, true);
ajax.onreadystatechange = function() {
  if (ajax.readyState == 4 && ajax.status == 200) {
   show.innerHTML = ajax.responseText;
  }
}
ajax.send(null);
}
hongqi162 2008-11-30
  • 打赏
  • 举报
回复
mark
kindwell 2008-11-30
  • 打赏
  • 举报
回复
常用功能?
neo_yoho 2008-11-30
  • 打赏
  • 举报
回复
??

52,797

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 Ajax
社区管理员
  • Ajax
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧