此代碼在數據庫中找到一個scu,並在您輸入時顯示它。它適用於除Firefox以外的所有瀏覽器(Chrome,IE,Opera)。如果任何人都能看到爲什麼我會非常感謝幫助。jQuery,php,mysql不能在firefox中工作
<!DOCTYPE html>
<head>
<meta charset="UTF-8">
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'></script>
<script src="chData_test.js"></script>
</head>
<body>
<form name="testForm">
<input type="text" name="scu" id="scu"><input type="button" id="theButton">
</form>
<div id="output"></div>
</body>
$(document).ready(function() {
$('#theButton').click(get);
$('#scu').keyup(get);
function get() {
$.post('data.php', {scu:testForm.scu.value}, function(output) {
$('#output').text(output).show();
});
}
});
<?php
mysql_connect("***.000webhost.com", "a9414387_***", "****");
$scu = mysql_real_escape_string($_POST['scu']);
if ($scu==NULL) {
echo "No entry scu found";
}
else {
$description = mysql_query("SELECT description FROM a9414387_***.inventory WHERE id LIKE '$scu%'");
$description_num_rows = mysql_num_rows($description);
if ($description_num_rows==0) {
echo "scu not found in database";
}
else {
$description = mysql_result($description, 0);
echo "You have selected the $description";
}
}
?>
以什麼方式做它不工作? – Blazemonger
看看JavaScript控制檯?有沒有錯誤?看看HTTP請求。數據是你期望的。看看PHP日誌。有沒有錯誤?看看正在生成的SQL。這是你期望的嗎?看看PHP正在做出的HTTP響應。這是你期望的嗎? *不要只說「它不工作」* – Quentin
它似乎沒有連接到PHP文件。當我輸入#時沒有任何反應。 – user1114060