I am trying to send a request to my server using jQuery/ajax: in this call, i need to transmit a string, a path to a file containing backslashes. However, all I get is something like this:
someText
Clearly, the backslashes are misinterpreted, so i tried using escape(), encodeURI() etc combined, each alone and various combinations, but still could not make it work.
This is my code:
<button onclick="Start('File', encodeURIComponent("some\Text"))">Click!</button> function Start(PlayerType, Pfad) { $.ajax({ url: "Player/Start", type: "get", data: { Typ: PlayerType, Pfad: Pfad }, dataType: "html", success: function (result) { $("#PlayerDIV").html(result); } }); } public ActionResult Start(string Typ, string Path) { Debug.WriteLine(HttpUtility.UrlDecode(Pfad)); //then returns the plain text without the \ ... }
Thank you for your help!