IE瀏覽器 ajax傳參數值爲中文時出現亂碼的解決方案

找了不少方法,發現就這個方法簡單、直接、方便,直接推薦哦!ajax

在漢字的位置加個保護措施:encodeURIComponent(parentid)url

舉個栗子>>>spa

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

              }
  });io

相關文章
相關標籤/搜索