Is there a javascript function that takes a string and converts it into another string that is percent-encoded? That way something like \"This Guy\" turns into \"This%20Guy\".>
Try this encodeURIComponent()
var stringToDecode = "J&K";
var encodedString = encodeURIComponent(stringToDecode );
Use decodeURIComponent()
to decode it again when needed
More Info here
https://en.wikipedia.org/wiki/Percent-encoding#Percent-encoding_reserved_characters
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent