如何在jquerypost中转义formData中的特殊字符?
我想传递$scope.data.responseFields=CustType,AddedDt。我已经尝试使用toString()将其作为字符串值,并将其作为数据传递。但我看到它是这样传递的:responsefeelds=custype%252CAddedDt 我试过用espace字符来压制“,”。但它仍然不起作用。有人能告诉我这到底是怎么回事吗如何在jquerypost中转义formData中的特殊字符?,jquery,angularjs,regex,Jquery,Angularjs,Regex,我想传递$scope.data.responseFields=CustType,AddedDt。我已经尝试使用toString()将其作为字符串值,并将其作为数据传递。但我看到它是这样传递的:responsefeelds=custype%252CAddedDt 我试过用espace字符来压制“,”。但它仍然不起作用。有人能告诉我这到底是怎么回事吗 $.post(tempURL,$scope.data).done(function(oResponse, status, xhR){
$.post(tempURL,$scope.data).done(function(oResponse, status, xhR){
if(null!=oResponse){
$scope.data = oResponse.result;
}
else
alert("error retrieving information");
$scope.$apply();
}).fail(function(oResponse, status, xhR){
alert(status);
});
在您的情况下,encodeURI应该可以工作:
encodeURI($scope.data)
您是否尝试过.serialize()
?没有。让我检查一下。我认为这不会奏效。因为在我的例子中,我直接将值分配给“responseFields”,这是我需要传递的唯一值。也许encodeURI
?为什么不使用$http服务而不是jQuery ajax!!