Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

119
Visualizações
$.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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda