zoukankan      html  css  js  c++  java
  • AJAx使用浏览器兼容的方式创建 异步对象

    //使用浏览器兼容的方式创建 异步对象
    function createXhr() {
        var xhobj = false;
        try {
            xhobj = new ActiveXObject("Msxml2.XMLHTTP"); // ie msxml3.0+
        } catch (e) {
            try {
                xhobj = new ActiveXObject("Microsoft.XMLHTTP"); //ie msxml2.6
            } catch (e2) {
                xhobj = false;
            }
        }
        if (!xhobj && typeof XMLHttpRequest != 'undefined') {// Firefox, Opera 8.0+, Safari
            xhobj = new XMLHttpRequest();
        }
        return xhobj;
    }

    //将序列化成json格式后日期(毫秒数)转成日期格式
    function changeDateFormat(cellval) {
        var date = new Date(parseInt(cellval.replace("/Date(", "").replace(")/", ""), 10));
        var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
        var currentDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
        return date.getFullYear() + "-" + month + "-" + currentDate;
    }

  • 相关阅读:
    JQuery学习四(过滤选择器)
    JQuery学习三(隐式迭代和节点遍历)
    JQuery学习二(获取元素控件并控制)
    JQuery学习一
    Dom中select练习
    DOM动态操纵控件案例
    DOM学习控件定位和案例
    DOM案例五星评分控件
    DOM动态增加控件
    DOM用TagName操作标签
  • 原文地址:https://www.cnblogs.com/ypfnet/p/2659362.html
Copyright © 2011-2022 走看看