Answer the question
In order to leave comments, you need to log in
Why is json not coming from the server?
Good afternoon!
I'm making a web face for the database. We work locally, my computer is equidistant segmentally like others. I get data using jquery - everything is fine on my computer, but others have an error. - Error: net::ERR_INCOMPLETE_CHUNKED_ENCODING ;
There is backend.php:
///...
if(isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') {
if(isset($_POST['json']) && $_POST['json'] == 'users') {
$string = json_encode(getUsers(), true);
echo $string;
}
exit();
}
function getUsers(){
global $DBH;
$STH = $DBH->prepare('correct sql');
$STH->execute();
$result =$STH->fetchAll(PDO::FETCH_ASSOC);
return $result;
}
//...
$.ajax({
dataType: "json",
url: 'backend.php',
data: {json:'users'},
success:function(data) {
var html = '';
// формирую табличку
$('.workers tbody').html(html);
}
});
header('Content-Type: application/json');
header('Content-Length: ' . mb_strlen($string));
Answer the question
In order to leave comments, you need to log in
I would recommend you Phalcon
A very nimble extension for PHP, written in C.
It is very powerful in itself, but there is a light version of Micro for the rest back-end:
docs.phalconphp.com/ru/latest/reference/micro.html
recently on the knee glued such a thing AngularJS + REST + Plain Phalcon, may be of interest:
https://github.com/zo0m/angularjs-phalcon-rest-ze-...
though I didn’t bring it to mind, or rather brought it already in the project, then if there is time I will finalize.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question