特殊字符“&”如何使用 XMLHttpRequest() 对象发送到服务器端

时间:2021-01-29 10:57:38

标签: javascript angularjs xmlhttprequest

我正在使用 XMLHttpRequest() 从 js 发送数据,但发送数据时不允许使用 & 如果我发送数据“Joe & Doe”,它只会接收 Joe 并解析 & 字符

这是代码

var req = new XMLHttpRequest();


        req.open("GET", 'generateListPDF?messageTemplateName=' + messageTemplateName +
            + "&accountTitle=" + $scope.accountsInfo.accountTitle
            + "&branchName=" + $scope.accountsInfo.branchName
            + "&searchCriteria=" + $scope.accountModel.searchCriteria
            , true);

        req.responseType = "blob";
          req.send();

如果我发送帐户标题“Joe & Doe”,它只会回复 JOE

0 个答案:

没有答案
相关问题