我有以下PHP块:
$word = mysql_real_escape_string(trim($_GET['word']));
$firstletter = substr('$word', 0, 1);
$query = "SELECT * FROM `dictionary` WHERE word LIKE '%$firstletter'";
$result = mysql_query($query) or die(mysql_error().": ".$query);
$row = mysql_fetch_assoc($result);
// send back the word to ajax request
$i = 0;
$fullLoad = '';
while ($i < mysql_numrows($result)) {
$fullLoad = $fullload . '|' . $row['word'];
$i++;
}
echo $fullLoad;
Run Code Online (Sandbox Code Playgroud)
现在,我的AJAX电话:
$.ajax({
type: "GET",
url: "word-list.php",
data: "word="+ theword,
success: function(data){ //data retrieved
console.log(data);
}
});
Run Code Online (Sandbox Code Playgroud)
现在,让我们假设缺少的单词变量是apple- 所以$word = 'apple';
但是当console.log()输出时 - 我得到的只有零,没有,nada,zip,blahblah
> :(
| 归档时间: |
|
| 查看次数: |
209 次 |
| 最近记录: |