javascript字符串包含\u0027,在concat字符串后面加'

vd2z7a6w  于 2021-09-23  发布在  Java
关注(0)|答案(1)|浏览(1020)

我正在尝试创建一个包含(')的字符串。当我发送ajax帖子以使用web服务时,发送的字符串包含\u0027。有帮助吗?

var SearchCriteria = "1=1"; 
        if (tblSYS_SubscribersSearch.value.length > 0) {
            SearchCriteria = "FirstName LIKE N'%" + Criteria + "%' OR LastName LIKE N'%" + Criteria + "%'";
        }
        var settings = {
            "url": "<%=ConfigurationManager.AppSettings["EndPoint"].ToString()%>" + "/api/SYS_Subscriber/GetListPaged",
            "method": "POST",
            "timeout": 0,
            "headers": {
                "Content-Type": "application/json"
            },
            "data": JSON.stringify({
                "ApiKey": Apikey,
                "Fields": Fields,
                "Criteria": SearchCriteria,
                "SortOrder": SortOrder,
                "SortDirection": SortDirection,
                "PageIndex": PageIndex,
                "PageSize": PageSize
            }),
        };
zc0qhyus

zc0qhyus1#

\u0027 是撇号(')的unicode字符
您需要为编码添加字符集utf-8
例子:

contentType: "application/json; charset=utf-8"

在html文件中,我们添加

<meta charset="utf-8">

参考:-https://www.utf8-chartable.de/

相关问题