I am trying to make a request using jQuery ajax, that contains &, where url:
var fileName = 'test&.pdf';
var resultUrl = url + encodeURIComponent(fileName);
So, the result url is /Download/cbe1952c-1b16-40bc-9f93-7a801e0e68b8/true/test%2526.pdf. But I retrieve server error HTTP Error 400 - Bad Request.
Any ideas?
EDIT:
I’ve found, that %2526 is a result of double escaping of amp, so, jQuery ajax escapes it by itself. The new problem is the server says about the potentially dangerous request, when url contains %26.
Try
encodeURIComponentThe result will be
/Download/cbe1952c-1b16-40bc-9f93-7a801e0e68b8/true/test%26.pdf