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

117
Views
$.post fails when including php file

I'm making a $post call to a .php file that return json data. It works just fine if I only use one .php, but if I try including another .php it drops into the .failed callback. I've put together an example here with an included .php that doesn't even do anything.

Javascript:

$.post("/test_php/cgi.php", l_cDB_arg_array, function(o) {
  console.log("Returned from db_interface call" + JSON.stringify(o));
  console.log(JSON.stringify(o));
  l_this.showLayer("top of the world", false);
}).fail(function(response) {
  console.log('Error: ' + JSON.stringify(response));
});

First cgi.php:

<?php
include "noop.php";

header("Content-Type: application/json; charset=UTF-8");


$ret = json_decode('{"some":"data"}');

echo json_encode($ret);

Second noop.php

<?php

Result when including noop.php in cgi.php

Error: {"readyState":4,"responseText":"{\"some\":\"data\"}","status":200,"statusText":"OK"}

Result when not including noop.php in cgi.php

Returned from db_interface call{"some":"data"}

Looking at all the .fail arguments I get:

response: {"readyState":4,"responseText":"{"some":"data"}","status":200,"statusText":"OK"}

textStatus: parsererror

errorThrown: SyntaxError: Unexpected token in JSON at position 0

Moving the header to before the include didn't change anything.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Installed eclipse, and edited the noop.php with it. I could see one more line in the file with the eclipse editor, that was showing in visual studio. Deleting the extra line with eclipse solved the problem.

about 4 years ago · Juan Pablo Isaza 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!