Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>check this out: <a href="https://github.com/aehlke/tag-it/issues/13" rel="noreferrer">How to get tagSource to work with $.ajax()?</a> (from tag-it's github issue list).</p> <p>this is an example: HTML file:</p> <pre><code>&lt;!doctype html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js" type="text/javascript" charset="utf-8"&gt;&lt;/script&gt; &lt;script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.12/jquery-ui.min.js" type="text/javascript" charset="utf-8"&gt;&lt;/script&gt; &lt;script src="js/tag-it.js" type="text/javascript" charset="utf-8"&gt;&lt;/script&gt; &lt;link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1/themes/flick/jquery-ui.css"&gt; &lt;link href="css/jquery.tagit.css" rel="stylesheet" type="text/css"&gt; &lt;script type="text/javascript"&gt; $(document).ready(function() { $("#mytags").tagit({ tagSource: function(search, showChoices) { $.ajax({ url: "auto.php", data: {search: search.term}, success: function(choices) { showChoices(choices); } }); } }); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;ul id="mytags"&gt; &lt;li&gt;Tag1&lt;/li&gt; &lt;/ul&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>(get tag-it.js file from [here][1])</p> <p>and this is the PHP file:</p> <pre><code>&lt;?php header('Content-type: application/json'); $q = $_GET["search"]; //check $q, get results from your database and put them in $arr $arr[] = 'tag1'; $arr[] = 'tag2'; $arr[] = $q; echo json_encode($arr); ?&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload