I am passing some parameters from UI to backend API. But, I want to encode those params before sending to backend.
I thought to use function encodeURIComponent(), but that will not help, as it is used for encoding the URLs.
dataInfo contains all the params that will be passed to backend.
var dataInfo = {};
dataInfo.pId = "584e88f472f94906b09e04a8";
dataInfo.aId = localStorage.aId;
dataInfo.fName = fName;
dataInfo.fJson = fJson;
dataInfo.userName = localStorage.username;
and dataInfo is getting passed to data while calling backend API.
$.ajax({
type: "POST",
url: localStorage.idataInfoApi,
data: JSON.stringify(dataInfo),
contentType: "text/html",
dataType: "html",
});
Please guide me on how can I encode the complete dataInfo into UTF encoded format, so that resulting data will be in byte[].