I want my ajax to return markup instead of raw text. Of course php can echo out labels or paragraphs etc. I have 2 functions:
file1:
function updateHtmlContent() {
var htmlContent = $('#new-users').text();
$.ajax({
type: "GET",
datatype: "object",
url: "newusers.php",
success: function(data) {
if (htmlContent != data) {
$('#new-users').text(data);
}
}
});
}
#new-users is just an empty div
File 2 :
session_start();
include("../class/Database.php");
$roomData = Database::query("SELECT * FROM users WHERE roomId = '".$_SESSION['roomcode']."'");
$roomData2 = Database::query("SELECT * FROM room WHERE code = '".$_SESSION['roomcode']."'");
foreach ($roomData as $name){
if ($name['username'] == $roomData2[0]['hostname']){
} else {
echo "<a href='#'>".$name['username']."</a>";
echo "<label>€".$name['money']."</label>";
}
}
But this just literally returns: <a href='#'> instead of just the markup with the content in it. I dont want the <a href='#'> to be visible just the text inside it