I've got some issues fetching a value from db by using ajax in my jquery script.
index.php:
<?php include 'db/db_connection.php';?>
<?php include 'db/db_getvalues.php';?>
<div class="arrow">
<img src="img/arrow_left.png" />
</div>
<div class="text-box"></div>
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 // This file works, i've selected data directly from html-file
<?php
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;
}
?>