js传递参数中包含+号时的处理方法

encodeURI(url).replace(/\+/g, '%2B')

例子:

$scope.getAnesthesiawaystatistical = function (annual, anesthesiaMethodRep) {
var Anesthesiurl = "/api/v1/AnesthesiAwayStatistical/GetAnesthesiAwayStatisticalCount?anesthesiaMethodRep=" + "'" + anesthesiaMethodRep + "'" + "&annual=" + annual;
alert(encodeURI(Anesthesiurl).replace(/\+/g, '%2B'));
$http.get(encodeURI(Anesthesiurl).replace(/\+/g, '%2B')).success(function (data) {

if (data.has_val) {
$scope.AnesthesiAwayStatisticalList = data.result;

console.log($scope.AnesthesiAwayStatisticalList);
}
});
}

posted on 2016-12-21 17:35  張暁磊  阅读(420)  评论(0编辑  收藏  举报