Hi pbötcher,
very strange - This (in my test file) does NOT work. Note: I added a j to $ and
Code: Select all
<script src="/resources/jquery/js/jquery-1.12.4.min.js"></script>
is included before. Without the j (so: $ only) it does work:
Code: Select all
<body>
<div id="wahl_ort_bereich">
<form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="get">
<div class="bgcolor">
<label class="demo-label">Search Country:</label><br/> <input type="text" name="txtCountry" onfocus="this.value=''" id="txtCountry" class="typeahead"/>
</div>
</form>
</div>
</body>
<?php $currPath = pathinfo($url); ?>
<script>
$j(document).ready(function () {
$j('#txtCountry').typeahead({
source: function (query, result) {
$j.ajax({
url: "<?php echo $currPath['dirname'];?>/hooks/containercodes.php",
data: 'query=' + query,
dataType: "json",
type: "POST",
maxRows: 15,
deferRequestBy: 100, //miliseconds
success: function (data) {
result($.map(data, function (item) {
return item;
}));
}
});
}
});
});
</script>
</html>
The ajax file containercodes.php looks like this (and works, see first animation below)
Code: Select all
<?php
//START AppGini Defaults
$currDir = dirname(__FILE__);
require("$currDir/../lib.php");
/* grant access to all users who have access to the orders table */
$user_can_access = get_sql_from('tblContainer');
if(!$user_can_access) exit(error_message('Access denied!', false));
//END AppGini Defaults
$keyword = strval($_POST['query']);
$keyword_safe = makeSafe($keyword);
$search_param = "%{$keyword_safe}%";
$result = sql("SELECT ContainerCode FROM tblContainer WHERE ContainerCode LIKE '".$search_param."'", $eo);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
$ContainerCodes[] = $row["ContainerCode"];
}
echo json_encode($ContainerCodes);
}
?>
This is the result which should be achived in the real file - but only works in the test-file:

- test_1.gif (138.35 KiB) Viewed 3098 times
This is the result in the real fiel (with the same
Code: Select all
url: "<?php echo $currPath['dirname'];?>/hooks/containercodes.php",
) as source:

- real_1.gif (174.88 KiB) Viewed 3098 times
In my "real" file, when I chance $ to $j no changes: From it does not work to it still does not work.
Olaf