我有一些问题通过在我的jQuery脚本中使用ajax从数据库获取值。
的index.php:使用ajax从数据库获取数据jquery
的script.js
$(document).ready(function() {
$(".arrow").click(function() {
$.ajax({
type: "GET",
url: "../db/db_getvalues.php", // This is the correct path, but do jquery recognize "../db/" etc?
dataType: "text",
success: function (response) { // Here is where i'm lost, what do i need to write to update my innerHTML with the returned value from the db_getvalues.php-file?
$(".text-box").html(response);
}
});
});
});
db_getvalues.php //此文件的工作,我已经直接从HTML文件
function getdbvalues() {
$query = 'SELECT * FROM mydb WHERE Id = 1';
$fetch = mysql_query($query) or die ('Could not find tablerow');
$row = mysql_fetch_assoc($fetch);
$textString = $row['Text'];
return $textString;
}
?>
+0
你目前得到的输出是什么? –
2014-11-22 15:38:42