$.get jquery function is returning a full html page instead of json in data

I'm developing a web app and I'm using php as server side language which return a JSON data here is the PHP script that is returning the JSON data:

require_once "connection.php";

if (isset($_GET['take'])) {

    $res = $conn->query('select * from pas where service=1');


if ($res->num_rows > 0) {
    $arr = array();
    while ($row = $res->fetch_assoc()) {
        array_push($arr, $row);
    header("Content-type: application/json");
    echo json_encode($arr);

the javascripte code is :

$.get('../controllers/sap.php?take=1', function(data) {
    console.log(data); //printing the result here

though yesterday it was working, that PHP page is the returned result....

the response

Answers 1

  • I figured out the problem,I was running the app from intelliJDea IDE on a diferent port than wamp server and php was not working on that port,but when I ran the app from wamp server it worked since php is wroking thats the solution never run a php related app from any ID thats the lesson of the day :).

Related Articles