ajax中get提交的时候改变参数的编码

前端之家收集整理的这篇文章主要介绍了ajax中get提交的时候改变参数的编码前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
function transUrlParaCode(para){
    var s = para;
    if (para != null){
        s = para.replaceAll("%","%25"); s = s.replaceAll(" ","%20"); s = s.replaceAll("/","%2F"); s = s.replaceAll("#","%23");
        s = s.replaceAll("\\+","%2B");
        s = s.replaceAll("\\?","%3F");
        s = s.replaceAll("&","%26");
        s = s.replaceAll("\\=","%3D");
    }
    return s;
}

jquery对查询到的数据中的非法字符进行转义,然后使用转义后的字符当作id使用。防止id中有些符号导致不能作为id使用。
//jquery 中对特殊字符转义

function jqTrans(str){
    if(str.length>0&&str.trim()!=""){
        str=str.replaceAll(" ","");
        str=str.replaceAll("#","");
        str=str.replaceAll("\\$","");
        str=str.replaceAll("=","");
        str=str.replaceAll("&","");
        str=str.replaceAll("@","");
    }
    return str;
}
原文链接:https://www.f2er.com/ajax/162411.html

猜你在找的Ajax相关文章