AJax技术

一个强健 实用的asp+ajax二级联动菜单(有演示和附源程序打包下载(2)

字号+ 作者:H5之家 来源:H5之家 2017-04-05 10:01 我要评论( )

function createxmlhttp() { xmlhttpobj = false; try{//创建对象,一个一个的试,哎,要是能统一标准都好。。 xmlhttpobj = new XMLHttpRequest; }catch(e){ try{ xmlhttpobj=new ActiveXObject("MSXML2.XMLHTTP")


function createxmlhttp()
{
xmlhttpobj = false;
try{//创建对象,一个一个的试,哎,要是能统一标准都好。。
xmlhttpobj = new XMLHttpRequest;
}catch(e){
try{
xmlhttpobj=new ActiveXObject("MSXML2.XMLHTTP");
}catch(e2){
try{
xmlhttpobj=new ActiveXObject("Microsoft.XMLHTTP");
}catch(e3){
xmlhttpobj = false;
}
}
}
return xmlhttpobj;
}
function getsubcategory(bigclassid){
if(bigclassid==0){
document.getElementById("subclass").innerHTML="<select><option value='0' selected>选择二级分类</option></select>";
return;
};
var xmlhttpobj = createxmlhttp();
if(xmlhttpobj){//如果创建对象xmlhttpobj成功
xmlhttpobj.open('get',"getsubcategory.asp?bigclassid="+bigclassid+"&number="+Math.random(),true);//get方法 加个随机数。
xmlhttpobj.send(null);
xmlhttpobj.onreadystatechange=function(){//客户端监控函数
if(xmlhttpobj.readystate==4){//服务器处理请求完成
if(xmlhttpobj.status==200){
//alert('ok');
var html = xmlhttpobj.responseText;//获得返回值
document.getElementById("subclass").innerHTML=html;
}else{
document.getElementById("subclass").innerHTML="对不起,您请求的页面有问题...";
}
}else{
document.getElementById("subclass").innerHTML="加载中,请梢候...";//服务器处理中
}
}
}
}


打包文件下载

 

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

相关文章
  • 蚂蚁社区,一个可以下载源码的神奇网站

    蚂蚁社区,一个可以下载源码的神奇网站

    2017-03-03 11:07

  • php判断一个请求是否是 AJAX 请求

    php判断一个请求是否是 AJAX 请求

    2017-02-26 08:03

  • 3款实用的在线JS代码工具(国外)

    3款实用的在线JS代码工具(国外)

    2017-02-25 11:04

  • 一个简单的ajax例子(带有清除ajax缓存的),苏州,网页设计建站技术

    一个简单的ajax例子(带有清除ajax缓存的),苏州,网页设计建站技术

    2017-02-22 16:01

网友点评