Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

130
Views
How to make ajax return markup instead of raw text

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

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!