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

191
Views
Why ajax reponse return whole php code not an echo variable

I have example code like this:

JQ:

$.ajax({
        type: 'GET',
        url: 'getData.php',
        success: function(data) {
            console.log(123);
            console.log(data);
            console.log(123);
        }
    });

PHP:

<?php
$text = "hello";
echo $text;
?>

And I get all code like this

enter image description here

Why is not show 「hello」?

I run on Mamp, isn't work?

Thanks!

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

you have to use this in PHP:

<?php

$text = "hello";

echo json_encode($text);

?>

and you have to pass

header('Content-Type: application/json');

Maybe it will helpful

over 4 years ago · Santiago Trujillo Report
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!