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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T14:23:40+00:00 2026-05-21T14:23:40+00:00

i am learning JSON. i just write a simple code which is not working

  • 0

i am learning JSON. i just write a simple code which is not working and also not giving any error when clicking on button. so please help me to catch the error. here is my html.

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>

    <script type="text/javascript" language="javascript">
        function GetJSON() 
        {
            alert("pp");

            var moviereviewtext = "{"title": "Friday the 13th", "year": 1980, "reviews": 
            [{"reviewer": "Pam", "stars": 3, "text": "Pretty good, but could have used more Jason"}, 
            {"reviewer": "Alice", "stars": 4, "text": "The end was good, but a little unsettling"}]}";
            var jsonobj = eval("(" + moviereviewtext + ")");

            var reviewername = jsonobj.reviews[0].reviewer;
            var numberstars = jsonobj.reviews[0].stars;
            var reviewerthoughts = jsonobj.reviews[0].text;

            alert(reviewername);
            alert(numberstars);
            alert(reviewerthoughts);
        }
    </script>
</head>
<body >
    <form id="form1" runat="server">
        <asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="GetJSON();return false;" />
    </form>
</body>
</html>
  • 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-05-21T14:23:41+00:00Added an answer on May 21, 2026 at 2:23 pm

    This is browser dependent but with a few small changes:

    // Use single quote to surround and line continuations to support new lines.
    var movieReviewText = 
        '{"title": "Friday the 13th", "year": 1980, "reviews":\
        [{"reviewer": "Pam", "stars": 3, "text": "Pretty good, but could have used more Jason"},\ 
        {"reviewer": "Alice", "stars": 4, "text": "The end was good, but a little unsettling"}]}';
    
    var obj = JSON.parse(movieReviewText); // This should be available IE8+, FF3+
    

    Also, take note that a function that starts with a capital letter is by convention considered a constructor. The name of your function also could be made better as the function does not actually get JSON. Maybe something like this?

    function parseMovieReview() {
    
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working with learning json right now and to get my feat wet
Learning some VBA. So far, I've constructed this piece of code which should allow
I'm just learning json. I'm trying to create an array of object Messages, The
I'm just learning how to utilise ajax/json with jquery and I've hit a brick
I am just learning server-side JavaScript so please bear with any glaring mistakes I've
I've been learning Php/SQL/JSON for just over 24 hours now and its gone pretty
I am trying to create a facebook application (just learning) which will show unicode
This is my first time learning json and this is my sample code: $(function
I've just started learning Sencha Touch. Trying to build a simple news reader app.
Currently I am trying to get javascript code working that I didn't write (and

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.