URL Encoding in Javascript

Although Javascript has following functions to encode URL, all the results will be different from PHP's urlencode():

  • encodeURI()
  • encodeURIComponent()

Solution:

Apply a plugin:  http://phpjs.org/functions/urlencode/

Reference: