Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7756539
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:51:00+00:00 2026-06-01T12:51:00+00:00

PHP5.1.6 has no json_encode(), so I wanted to use function found on json_encode documentation

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T12:51:01+00:00Added an answer on June 1, 2026 at 12:51 pm

    When the json file can’t be converted it throws parsererror exception, so try this:

      $.ajax({
        url: 'article.php',
        type: 'POST',
        data:  { id: $(this).data( 'id_prod' ) },
        dataType: 'json',
        success: function( results ) {
          console.log('finished');
          console.log(results);
        },
        error: function(jqXHR, textStatus, errorThrown) { 
          console.debug(jqXHR, textStatus, errorThrown); 
        }
      });
    

    It will output your error when the JSON is invalid.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I'm trying to parse an incoming request in PHP which has the following
I am new to mongodb and thinking of trying this out in PHP5. If
I'm trying to use Json with my database using php5 but suffering from a
I've taken over a mixed PHP4/PHP5 project which has been handed down from developer
I'm using PHP5 to create XML files. I have code like this: $doc =
Im building a codeigniter app which uses json_encode to provide ajax data in many
It gives me the following message: The requested URL /cgi-sys/php-cgiwrap/gcadmin/php5.cgi/projects/globalcolleage/index.php was not found on
My site was working fine until I followed this guide, http://www.howtoforge.com/how-to-set-up-apache2-with-mod_fcgid-and-php5-on-ubuntu-9.10 to set up
This error has been driving me nuts. We have a server running Apache and
On a symfony production server, an automatic update has uninstalled libapache2-mod-php5. So after that,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.