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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:09:10+00:00 2026-06-09T17:09:10+00:00

I am having trouble displaying some jason from a page. The data is there

  • 0

I am having trouble displaying some jason from a page.

The data is there but I think it might have to do with this line:

document.write(fbResults.cats[0].title);

Here is the full html source:

<!DOCTYPE HTML>
<html>
<head>
<title></title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>

<script>

    $(document).ready(function() {
        $.getJSON('http://mydomain.com/api/get_cats', function(fbResults) {
            document.write(fbResults.cats[0].title);
        });
    });
</script>

</head>
<body>

</body>
</html>

And here is the data that it’s reading:

{"cats":[

{"id":"1","title":"mytitle1","colour":"#EE297C"},
{"id":"2","title":"mytitle2","colour":"#EE412F"},
{"id":"3","title":"mytitle3","colour":"#F5821F"},
{"id":"4","title":"mytitle4","colour":"#00AEEF"},
{"id":"5","title":"mytitle5","colour":"#00B495"},
{"id":"6","title":"mytitle6","colour":"#006476"}

]}

It is not displaying anything on the page.

On firebug console I get this error:

The character encoding of the HTML document was not declared. The document will render with garbled text in some browser configurations if the document contains characters from outside the US-ASCII range. The character encoding of the page must to be declared in the document or in the transfer protocol.

No traces of the json data there

What I’m I doing whong?

  • 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-09T17:09:12+00:00Added an answer on June 9, 2026 at 5:09 pm

    You shouldn’t document.write after the page has loaded (which is certainly the case here).

    If you want to write it to the page, you’ll need to create HTML and append it. Just replace the document.write:

    $('body').append('<p>'+fbResults.cats[0].title+'</p>');
    

    Update:

    Your example makes a fully qualified URL call. Is that server the exact same one that you’re running the page from? If it isn’t the XHR will just eat the request (and sometime not tell you). If you need to go cross domain, you’ll need to use JSONp. If you’re attempting to run this locally while pulling data from the net, it’ll break.

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

Sidebar

Related Questions

I have a simple login page but i am having trouble displaying the logged
I'm having some trouble with displaying results from a datasource. This code will show
I am having trouble displaying results recieved from asp.net WebMethod. I have a HTML
I'm having trouble with displaying image from db. I think that method for saving
I'm having some trouble displaying the time in this format: HH:mm:ss. No matter what
I am having some trouble with this. We basically have been asked to create
I'm trying to scrape some information from a web site, but am having trouble
I'm having some trouble with displaying numbers in apex, but only when i fill
OK, this is an amateur question but I am having the most trouble displaying
Having trouble displaying MonthName in a DataGridView from data in MySQL Query: SELECT ItemName,

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.