aboutsummaryrefslogtreecommitdiffstats
path: root/demos/autocomplete/search.php
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2016-09-01 15:55:25 -0400
committerScott González <scott.gonzalez@gmail.com>2016-09-01 15:55:25 -0400
commit930934f4d22ce4397bcc85cde33c32acef2ec622 (patch)
tree9d7db6cc6973bdc5beaf68c81b3fe9e7174970a9 /demos/autocomplete/search.php
parent586d572ad2667f8f4c974f9e48d8ce7a4519af0c (diff)
downloadjquery-ui-930934f4d22ce4397bcc85cde33c32acef2ec622.tar.gz
jquery-ui-930934f4d22ce4397bcc85cde33c32acef2ec622.zip
Autocomplete: Change JSONP demo to use local data source
Fixes #14974
Diffstat (limited to 'demos/autocomplete/search.php')
-rw-r--r--demos/autocomplete/search.php13
1 files changed, 9 insertions, 4 deletions
diff --git a/demos/autocomplete/search.php b/demos/autocomplete/search.php
index 04bda4224..489b30c1e 100644
--- a/demos/autocomplete/search.php
+++ b/demos/autocomplete/search.php
@@ -1,6 +1,6 @@
<?php
-sleep( 3 );
+sleep( 2 );
// no term passed - just exit early with no response
if (empty($_GET['term'])) exit ;
$q = strtolower($_GET["term"]);
@@ -573,7 +573,6 @@ $items = array(
"Heuglin's Gull"=>"Larus heuglini"
);
-
$result = array();
foreach ($items as $key=>$value) {
if (strpos(strtolower($key), $q) !== false) {
@@ -584,6 +583,12 @@ foreach ($items as $key=>$value) {
}
// json_encode is available in PHP 5.2 and above, or you can install a PECL module in earlier versions
-echo json_encode($result);
+$output = json_encode($result);
+
+if ($_GET["callback"]) {
+ $output = $_GET["callback"] . "($output);";
+}
+
+echo $output;
-?> \ No newline at end of file
+?>