Answer the question
In order to leave comments, you need to log in
Correct encoding of values during ajax request - how to fix it?
All my adult life I had no problems with this, I always sent such ajax requests, but today the backend showed me what I was doing wrong.
The site has many filters, one of which is the search bar.
Changing any filter changes the address bar using History.pushState, adding/removing variables.
With an ajax request, I simply get the value of each variable from the address and send it as an object to the server.
Thus, the search string has the corresponding kind of URL encoding.
And then the backend tells me that there should be a normal string of Russian characters, because Laravel cannot find anything for such a request.
But in my practice, this is generally the first time that the server does not eat such a request.
Do I need to decode this string on my side or is the backend lazy?
Answer the question
In order to leave comments, you need to log in
xhr.setRequestHeader('Content-Type', 'application/json; charset=utf-8');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question