At the moment when I hover over any word a black box is always showing. If the PHP code returns text it is displayed in the black box (which it should). However I want it to return an error function if the text is not returned so I can then later change the CSS for the black box so that it has a width of 0px
instead of 400px
.
var x = ($(this).text());
$.ajax({
type: 'POST',
url: 'process.php',
data: { text1: x },
success: function(response){
$('#tooltip').text(response);
}
});
try
{
$db = new PDO('sqlite:ordbas.db');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch(PDOException $err)
{
echo "PDO fel $err";
}
if (isset($_POST['text1'])) {
$text1 = $_POST['text1'];
$results = $db->prepare("SELECT forord FROM words WHERE sokord='$text1'");
$results->execute();
$row = $results->fetch();
echo $row[0];
}
As you might have figured out there is some non-important code that I left out. I hope someone can understand and help me! Thanks!