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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:49:50+00:00 2026-06-10T04:49:50+00:00

I am having issues with my JSON_encode and jQuery, I am getting it to

  • 0

I am having issues with my JSON_encode and jQuery, I am getting it to post the full array with the following code, but I can’t get it to echo just the one array I need.

$.get("/indexget.php", { page: "goals" },function(data) {
$('#bodyContentStuff').text(data);

Full jQuery code

$("#navLinkGoals").click(function () {
    $("#bodyTitleBar").text("Goals");
    $.get("/indexget.php", { page: "goals" },function(data) {
        $('#bodyContentStuff').text(data);
    }
);

Full PHP code

if($_REQUEST['page'] = 'goals'){
    $result = mysql_query("SELECT * FROM content WHERE page='indexGoals'") 
    or die(mysql_error()); 
    $row = mysql_fetch_array( $result );
    $message = $row['message'];
}
echo json_encode(array("content"=>"$message"));

I am sort of a noob with programming, but the site is http://www.gronge.com if you’d like to see what it is doing, just click the goals link.

Edit: Oh, I have also tried

$('#bodyContentStuff').text(data['content']);

But it didn’t work.

  • 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-10T04:49:52+00:00Added an answer on June 10, 2026 at 4:49 am

    Have you logged the data variable? What does it log? Also: mysql_* is deprecated, steer clear and start using PDO. But I think you meant to assign $row[0]['message'] to the $message variable. If memory serves me well, mysql_* always returns either an array of assoc arrays, or an array of arrays.

    While we’re on the subject: JavaScript doesn’t have assoc arrays, only objects, so rather then accessing the data like data['content'], use data.content. The bracket notation is there for convenience, so you can use the value of a variable as property name (without eval), which is EVIL, of course.

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

Sidebar

Related Questions

I am trying to get facebook wall but I am having issues with JSON
I'm having some issues because I'm trying to re-use code (which can be used)
I'm having some issues to deserialize a Json array that follows this format: [
Still having issues with this problem. Please help if you can. So I am
I am having issues calling an ASP.NET web service in JQuery. I am basically
I am having issues getting the network.request function in Corona SDK working with a
I am having issues with storing JSON data to sqlite. This is the code
I am trying to do a simple JSON return but I am having issues
Having issues getting myself started on MVC3 Trying to define a simple route here
I have installed Eggdrop on a new Debian server, but it keeps having issues

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.