I am developing a web page where a user searches for files using tags. I am using jQuery Ajax to make a remote API call (database). Everything works fine when I use non-specific characters like az, but it doesn't work, for example using åäö.
On the server I use PHP. I print the tag to see if it’s coming, and all az work fine, but åäö does not appear at all. They do not seem to "come."
What could be wrong?
This is my jQuery code:
var tags = $('#tags').val(); $.ajax ({ type: "POST", url: base_url + "search", data: "tags=" + tags + "&limit=" + limit, beforeSend: function (html) { $("#search_results").html("Searching for files..."); }, success: function (html) { $("#search_results").html(html); }, error: function (html) { $("#search_results").html('Something went wrong!'); } });
This is my server side code:
echo ($_POST['tags']);
I searched and looked for related questions about this here on SO, but didn't help me, unfortunately.
UPDATE
Using this, I decided! Now it works fine.
{tags: encodeURIComponent(tags), limit: limit}
source share