我有PHP的以下塊:PHP AJAX和mySQL不返回數據?
$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;
現在,我的AJAX調用:
$.ajax({
type: "GET",
url: "word-list.php",
data: "word="+ theword,
success: function(data){ //data retrieved
console.log(data);
}
});
現在,讓我們假設所缺少的單詞變量是apple
- 所以$word = 'apple';
但是,當console.log()輸出 - 所有我得到的是零,沒有,虛無,拉鍊,blahblah
> :(
如果你瀏覽到word-list.php?word = apple? – 2011-02-06 14:50:04
不,我只是得到一個空白的窗口 - 沒有來源:( – 2011-02-06 14:53:12
是錯誤報告? – 2011-02-06 14:54:41