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 8831957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T08:25:25+00:00 2026-06-14T08:25:25+00:00

I am currently working on a php/html/javascript project and am doing ajax post to

  • 0

I am currently working on a php/html/javascript project and am doing ajax post to a php script which returns json encoded data. Within this json encoded there is some more json encoded data.

Below is how I am json encoding the data

$category[0]['Category'] = "Category 1";
    $category[1]['Category'] = "Category 2";

    $article['Date'] = "11/11/2012 22:42:00";
    $article['Title'] = "This is the title";
    $article['Subtitle'] = "This is the subtitle";
    $article['Content'] = "This is the content1";
    $article['ViaName'] = "SomeSite";
    $article['ViaAddress'] = "http://localhost";
    $article['SourceName'] = "N/A";
    $article['SourceAddress'] = "N/A";
    $article['categories'] = json_encode($category);

    echo json_encode($article);

The $article that gets json encoded I can access fine when it is returned to the javascript using json.Title, json.Subtitle etc.

But when I try and get the categories it doesn’t work.

I’ve tried using json.categories and this prints out the following:

[{"Category":"Category 1"},{"Category":"Category 2"}]

This looks like its working so when I try and access each individual part it then doesn’t work. I’ve tried json.categories[0].Category and json.categories.Category[0] but it keeps on coming up an undefined.

Thanks for any help you can provide.

  • 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-14T08:25:26+00:00Added an answer on June 14, 2026 at 8:25 am

    If you encode an array with json_encode you got a string. So, in your case, json.categories is a string and not an array.

    However, json_encode (and decode) is recursive.

    So you should use simply

    $article['categories'] = $category;
    

    without encode again.

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

Sidebar

Related Questions

I am currently working on a fun project, which involves Ajax, HTML, JavaScript, PHP
I am currently working on a php/html/javascript project. I have a form where when
Currently i have a working PHP edit script, which allows users to edit ads
I am currently working on an html and php project. What I want to
We currently have a working php mail script, this works fine and as we
Web programmer here - using AJAX (HTML, CSS, JavaScript, AJAX, PHP, MySQL), but for
I'm currently working on a PHP application that uses a MySQL database for its
I am currently working on a PHP application that puts me in the desperate
I'm currently working on a simple php function for an entity in the framework
I'm currently working on an OO PHP application. I have a class called validation

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.