• 一段可以判断浏览器的ajax的js代码



    var objRequest;
    function SendValue(val)
    {
    //初始化
    try
    {//MS IE浏览器
    objRequest=new ActiveXObject("Msxml2.XMLHTTP");}
    catch(e)
    {
    try
    {//所有的非IE浏览器
    objRequest=new ActiveXObject("Microsoft.XMLHTTP");}
    catch(oc)
    {objRequest=null;}
    }
    if(!objRequest&&typeof XMLHttpRequest!="undefined")
    {objRequest=new XMLHttpRequest();}
    //处理请求的Web页面
    var url="http://localhost/VBNETSample/HandleAjaxRequests.aspx?sStringIn=" + val;
    if(objRequest!=null)
    { objRequest.onreadystatechange = Process;
    objRequest.open("GET", url, true);
    objRequest.send(null);
    }
    }
    function Process()
    {
    if (objRequest.readyState == 4)
    //值"4"意味着,我们现在可以使用XMLHttpRequest返回的数据
    { if (objRequest.status == 200)
    { document.getElementById("txtEchoOutPut").innerText = objRequest.responseText;
    //IE
    //document.getElementById("txtEchoOutPut").innerHTML = objRequest.responseText;
    //另外的浏览器
    }
    else
    { document.getElementById("txtEchoOutPut").innerHTML= "There was a problem retrieving
    data:<br>" + objRequest.statusText;}
    }
    }
    var objRequest;function SendValue(val){//初始化try{//MS IE浏览器objRequest=new ActiveXObject("Msxml2.XMLHTTP");}catch(e){try{//所有的非IE浏览器objRequest=new ActiveXObject("Microsoft.XMLHTTP");}catch(oc){objRequest=null;}}if(!objRequest&&typeof XMLHttpRequest!="undefined"){objRequest=new XMLHttpRequest();}//处理请求的Web页面var url="http://localhost/VBNETSample/HandleAjaxRequests.aspx?sStringIn=" + val;if(objRequest!=null){ objRequest.onreadystatechange = Process;objRequest.open("GET", url, true);objRequest.send(null);}}function Process(){if (objRequest.readyState == 4)//值"4"意味着,我们现在可以使用XMLHttpRequest返回的数据{ if (objRequest.status == 200){ document.getElementById("txtEchoOutPut").innerText = objRequest.responseText;//IE//document.getElementById("txtEchoOutPut").innerHTML = objRequest.responseText;//另外的浏览器}else{ document.getElementById("txtEchoOutPut").innerHTML= "There was a problem retrievingdata:<br>" + objRequest.statusText;}}}
  • 相关阅读:
    Matlab之rand(), randn(), randi()函数的使用方法
    matlab给图片插入说明文字
    matlab之find()函数
    excel根据数据源变化的动态图表
    高斯坐标
    (转)Mysql技术内幕InnoDB存储引擎-表&索引算法和锁
    (转)MySQL 插入数据时,中文乱码问题的解决
    (转)防止人为误操作MySQL数据库技巧一例
    (转)mysql explain详解
    (转)一个MySQL 5.7 分区表性能下降的案例分析
  • 原文地址:https://www.cnblogs.com/chinatefl/p/1181849.html
Copyright © 2020-2023  润新知