Use encodeURIComponent() instead of encodeURI().