加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-16 01:43:01 所属栏目:百科 来源:网络整理
导读: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 =
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;
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读