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

Posted 張暁磊

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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);
}
});
}












以上是关于js传递参数中包含+号时的处理方法的主要内容,如果未能解决你的问题,请参考以下文章