PHP5.1.6 has no json_encode(), so I wanted to use function found on json_encode documentation. I am trying to use output of this function with ajax request:
fetchArticles: function( e ) {
$.ajax({
url: 'article.php',
type: 'POST',
data: { id: $(this).data( 'id_prod' ) },
dataType: 'json',
success: function( results ) {
console.log('finished');
console.log(results);
}
});
In article.php
I have at this time:
if ( isset($_POST['id']) ) {
connect();
$articles = get_articles( $_POST['id'] );
echo json_encode( $articles ); return;
}
The problem is with returning results to JS console:
- if there is no results, empty array is printed,
- if there is one results, proper object is printed,
- but when there is more than one result nothing is being printed to console, not even word
finished
.
I can see in HTTP headers and responses that proper data is returned, but it is not printed to console. Could you help me with solving this problem?