js传递参数中包含+号时的处理方法
2016-12-21 17:35
267 查看
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);
}
});
}
例子:
$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);
}
});
}
相关文章推荐
- .net中js向后台传递包含中文的参数,后台获取到的中文乱码的解决方法。
- js方法传递包含反斜杠\的参数时,会把\过滤掉
- js中setTimeout方法重写,实现对象参数传递
- PHP 传递同名参数处理方法
- JS中定义对象方式二: 使用工厂方式创建对象(传递参数,及其改进方法)
- 让JS中settimeout、setInterval调用传递参数 的好方法
- js的request方法,对“获取静态文件传递参数的函数” 进行了优化
- js传递中文参数的url到asp(jscript)解释得到的中文参数为乱码的解决方法
- JS通过URL传递参数时出现乱码的处理
- 传递Eval参数到js方法
- js--dom--添加事件的时候传递参数的方法
- URL传递参数包含特殊字符的处理
- JS 接收HTML传递参数的方法。
- java中需要注意的地方,包含方法传递参数等
- BASE64-客户端(js)加码-服务器端(c#)解码,URL传递“汉字参数”解决方法。
- BASE64-客户端(js)加码-服务器端(c#)解码,URL传递“汉字参数”解决方法
- 利用js方法实现html静态页面间参数传递
- javascript BASE64-客户端(js)加码-服务器端(c#)解码,URL传递“汉字参数”解决方法
- 过JS向PHP页面传递中文参数的两种方法
- Js中setInterval、setTimeout不能传递参数问题 及各自的关闭方法