IE浏览器 ajax传参数值为中文时出现乱码的解决方案

找了很多方法,发现就这个方法简单、直接、方便,直接推荐哦!

在汉字的位置加个保护措施:encodeURIComponent(parentid)

举个栗子>>>

    $.ajax({
             url: 'url'+ encodeURIComponent("中文参数值"),
              type: 'GET',
              dataType: 'JSON',
              timeout: 5000,
              error: function() { alert('error msg'); },
              success: function(resp) {
                 console.log(resp);

              }
  });

posted @ 2018-10-29 17:39  手指键盘摩擦  阅读(1952)  评论(0编辑  收藏  举报