1

did javascript or jquery has method as Server.UrlEncode() in asp.net

eg:when using

  $.get("a.aspx?pk=1&k="+kvale, function(data) {
            dosth(data);
            });

url must encode

SleeplessKnight
  • 2,125
  • 4
  • 20
  • 28
  • Duplicate: http://stackoverflow.com/questions/848715/what-is-the-javascript-equivalent-of-c-server-urlencode – Adam Butler Sep 22 '11 at 03:36
  • possible duplicate of [How to encode a URL in Javascript?](http://stackoverflow.com/questions/332872/how-to-encode-a-url-in-javascript) – Joseph Silber Sep 22 '11 at 03:36

1 Answers1

3

You can convert any string to a URL-encoded string (suitable for transmission as a query string or, generally speaking, as part of a URL) using the JavaScript functions escape, encodeURI and encodeURIComponent.

escape('https://www.stackoverflow.com/?wow.php')
"https%3A//www.stackoverflow.com/%3Fwow.php"

Source: http://www.javascripter.net/faq/escape.htm

Mohsen
  • 64,437
  • 34
  • 159
  • 186