In my JS, I am using jQuery ajax function.
Here's what it looks like:
$.ajax({
url: "somepage/" + keyword + "/" + xyz + "/" + abc + "/getbla",
(...)
If "keyword" (= text field value) contains "#", this no longer works. We all know that the URL will be processed only until # is reached, and the rest for # will be used, for example, for binding.
So, I changed the ajax function to this:
$.ajax({
url: "somepage/" + encodeURIComponent(keyword) + "/" + xyz + "/" + abc + "/getbla",
(...)
This did not work either, but in the console I see the full URL with% 23 instead of #.
Well, that was close to what I was looking for, but the request still does not work - I don't know why - that's why I ask here.
I typed% 23 in the text box (= keyword) and the query works completely. My php backend sends back the data I was looking for.
So this is my final decision:
$.ajax({
url: "somepage/" + encodeURIComponent(encodeURIComponent(keyword)) + "/" + xyz + "/" + abc + "/getbla",
(...)
Here's what the PHP function looks like:
if ($_GET['anyparam'] == 'getbla') {
$searchString = array(
'keyword' => trim($_POST['keyword']),
'xyz' => trim($_POST['xyz']),
'abc' => trim($_POST['abc'])
);
echo json_encode($this->dataBaseFunctions->searchResult($searchString['keyword'], $searchString['xyz'], $searchString['abc']));
}
: URL?