0
こんにちは、私はこのプラグインを今まで最高のものにしました。そして、私は jQuery Plugin: Tokenizing Autocomplete Text EntryJquery ajax autocomplete plugin
をしたいが、どのように私は働くdoesntのそれと私自身のPHPファイルを作成しようとしたとき
私のPHPファイルは:
<?php
$arr= array(
array("id"=>1,"name"=>"Ruby"),
array("id"=>1,"name"=>"Kritya")
);
var_dump($arr);
$json_response = json_encode($arr);
$json_response = $_GET["callback"] . "(" . $json_response . ")";
echo $json_response;
?>
彼らは私の持っていたをsample.phpファイルを与えましたこの:
<?
#
# Example PHP server-side script for generating
# responses suitable for use with jquery-tokeninput
#
# Connect to the database
mysql_pconnect("host", "username", "password") or die("Could not connect");
mysql_select_db("database") or die("Could not select database");
# Perform the query
$query = sprintf("SELECT id, name from mytable WHERE name LIKE '%%%s%%' ORDER BY popularity DESC LIMIT 10", mysql_real_escape_string($_GET["q"]));
$arr = array();
$rs = mysql_query($query);
# Collect the results
while($obj = mysql_fetch_object($rs)) {
$arr[] = $obj;
}
# JSON-encode the response
$json_response = json_encode($arr);
# Optionally: Wrap the response in a callback function for JSONP cross-domain support
if($_GET["callback"]) {
$json_response = $_GET["callback"] . "(" . $json_response . ")";
}
# Return the response
echo $json_response;
?>
私はそれがデータベースからデータを取得したいいけないが、私はHTMLのPAGにこれを使用しようとすると、単にアレイを使用するか、XMLファイルからデータを取得します電子
<h2 id="theme">Facebook Theme</h2>
<div>
<input type="text" id="demo-input-facebook-theme" name="blah2" />
<input type="button" value="Submit" />
<script type="text/javascript">
$(document).ready(function() {
$("#demo-input-facebook-theme").tokenInput("/test.php", {
theme: "facebook"
});
});
</script>
</div>
それはふてくされて私の配列構造を持ついくつかのエラーが発生している私のファイルで....私は彼らのウェブサイトのPHPファイルを入れたときに正常に動作しますが、検索すると言って続けています。
ハズレdoesntの作品を – kritya