最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

JavaScript 封裝Ajax傳遞的數(shù)據(jù)代碼

 更新時(shí)間:2009年06月05日 22:34:19   作者:  
在使用Ajax傳輸數(shù)據(jù)時(shí),少不了對傳遞的字符進(jìn)行轉(zhuǎn)碼,我的實(shí)現(xiàn)方式是將需要傳遞的數(shù)據(jù)暫存到一js Bean中,將js Bean放到Array中,生成傳輸參數(shù)時(shí)對Array中的jsBean進(jìn)行分解,得到相應(yīng)屬性信息并編碼..
復(fù)制代碼 代碼如下:

var paramBeanList = new Array();
Array.prototype.addParamBean=function(paramBeanObj){
    var index = this.containParamBean(paramBeanObj);
    if (index != -1) {
        this[index] = paramBeanObj;
    } else {
        this.push(paramBeanObj);
    }
};
Array.prototype.clear=function(){
    if (this.length == 0) {
        return;
    }
    for (var index in this) {
        this.pop();
    }
};
Array.prototype.containParamBean=function(paramBeanObj){
    var index = -1;
    if (this.length == 0) {
        return index;
    }
    for (var tempIndex = 0, step = this.length; tempIndex < step; tempIndex++) {
        if (this[tempIndex].compare(paramBeanObj) == 0) {
            index = tempIndex;
            break;
        }
    }
    return index;
};
var ParamBean = new function(pkCode, opDate, value) {
    this.pkCode = pkCode;
    this.opDate = opDate;
    this.value = value;
};
ParamBean.prototype={
toString:function() {
return "[pkCode:" + this.pkCode + ",opDate:" + this.opDate +",value:" + this.value + "]";
    },
    doVerify:function() {
        return (this.pkCode ? this.opDate ? this.value ? "true" : "false" : "false" : "false");
    },
    compare:function(otherObj) {
        var result = -1;
        if (otherObj) {
            if (this.pkCode == otherObj.pkCode && this.opDate == otherObj.opDate
                && this.value == otherObj.value) {
                result = 0;
            }
        }
        return result;
    }
};
var ParamUtils = new Object();
ParamUtils.doCreateAjaxStr=function() {
    var paramStr = "";
    if (paramBeanList.length == 0) {
        return paramStr;
    }
    var keyParamArray = new Array();
    var valueParamArray = new Array();
    for (var index = 0, step = paramBeanList.length; index < step; index++) {
        var tempObj = paramBeanList[index];
        keyParamArray.push(tempObj.pkCode + "`" + tempObj.opDate);
        valueParamArray.push(tempObj.value);
    }
    paramStr = "KEY_PARAM=".concat(encodeURIComponent(keyParamArray.join(","))).concat("&").concat("VALUE_PARAM=".concat(encodeURIComponent(valueParamArray.join(","))));
    return paramStr;
};

這篇文章我寫了一會,到了csdn上弄了半天提不上去,我用IE6切到高級編輯,內(nèi)容直接就是空,最后用Firefox瀏覽器竟然又提上來了。。

相關(guān)文章

最新評論

航空| 绥芬河市| 宁陕县| 和静县| 北海市| 鄯善县| 霍州市| 龙游县| 皮山县| 丰都县| 江口县| 荥经县| 定西市| 伽师县| 仁化县| 长宁县| 仪陇县| 雅江县| 盐亭县| 绵阳市| 虎林市| 任丘市| 双城市| 沽源县| 宜兰市| 万盛区| 怀集县| 民勤县| 绵竹市| 宣武区| 宣汉县| 柳林县| 蒙自县| 垣曲县| 察雅县| 湘乡市| 汉沽区| 南召县| 松桃| 青州市| 哈密市|