angularjs中$http POST中文参数乱码

  1. $http({    
  2.             method: "POST",    
  3.             url: "",    
  4.             data: id,    
  5.             headers: { 'Content-Type''application/x-www-form-urlencoded;charset=utf-8' },    
  6.             transformRequest: function(obj) {    
  7.                 var params= [];    
  8.                 for (var p in obj) {
  9.                  //判断参数值是否存在,不存在赋空   
  10.                   if(!obj[p])
  11.                          obj[p]='';
  12.                     params.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));    
  13.                 }    
  14.                 return params.join("&");    
  15.             }  
  16.         }).success();   

你可能感兴趣的:(javaScript)