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

  • Home
  • SEARCH
  • 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 1095141
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:04:39+00:00 2026-05-17T00:04:39+00:00

I have been struggeling all day to read a json file from server and

  • 0

I have been struggeling all day to read a json file from server and view it via dojo datagrid. Please see the code snippets below and help me if possible :

the html file is ::

<head>
    <link rel="stylesheet" type="text/css" href="../../_static/js/dijit/themes/claro/claro.css"
    />
    <style type="text/css">
        body, html { font-family:helvetica,arial,sans-serif; font-size:90%; }
    </style>
    <style type="text/css">
        @import "../../_static/js/dojox/grid/resources/Grid.css"; @import "../../_static/js/dojox/grid/resources/claroGrid.css";
        .dojoxGrid table { margin: 0; } html, body { width: 100%; height: 100%;
        margin: 0; }
    </style>
</head>

<body class=" claro ">
    <div id="gridContainer4" style="width: 100%; height: 100%;">
    </div>
</body>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/dojo/1.5/dojo/dojo.xd.js" djConfig="parseOnLoad: true">
</script>
<script type="text/javascript">
dojo.require("dojo.data.ItemFileReadStore");
        dojo.require("dijit.form.ComboBox");
        dojo.require("dijit.form.Button");        
dojo.require("dojox.grid.DataGrid");
    dojo.require("dojox.data.CsvStore");

    dojo.addOnLoad(function() {
        // our test data store for this example:
        var store4 = new dojo.data.ItemFileReadStore({
    url: "http://localhost/test1.json"});

        // set the layout structure:
        var layout4 = [{
            field: 'abbr',
            name: 'Title of Movie',
            width: '200px'
        },
        {
            field: 'name',
            name: 'Year',
            width: '50px'
        },
        {
            field: 'capital',
            name: 'Producer',
            width: 'auto'
        }];

        // create a new grid:
        var grid4 = new dojox.grid.DataGrid({
            query: {
                abbr: '*'
            },
            store: store4,
            clientSort: true,
            rowSelector: '20px',
            structure: layout4
        },
        document.createElement('div'));

        // append the new grid to the div "gridContainer4":
        dojo.byId("gridContainer4").appendChild(grid4.domNode);

        // Call startup, in order to render the grid:
        grid4.startup();
    });
</script>
<!-- NOTE: the following script tag is not intended for usage in real
world!! it is part of the CodeGlass and you should just remove it when
you use the code -->
<script type="text/javascript">
    dojo.addOnLoad(function() {
        if (document.pub) {
            document.pub();
        }
    });
</script>

The json is ::

{ identifier: 'abbr',
          label: 'name',
          items: [
                { abbr:'ec', name:'Ecuador',           capital:'Quito' },
                { abbr:'eg', name:'Egypt',             capital:'Cairo' },
                { abbr:'sv', name:'El Salvador',       capital:'San Salvador' },
                { abbr:'gq', name:'Equatorial Guinea', capital:'Malabo' },
                { abbr:'er', name:'Eritrea',           capital:'Asmara' },
                { abbr:'ee', name:'Estonia',           capital:'Tallinn' },
                { abbr:'et', name:'Ethiopia',          capital:'Addis Ababa' }
        ]}
  • 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-17T00:04:40+00:00Added an answer on May 17, 2026 at 12:04 am

    I am not use dojo, but if the file content of test1.json is really as you wrote at the end of your post, then it is wrong. In JSON format all property names and all strings must be double quoited. So try to replace the test1.json file with the following

    {
        "identifier": "abbr",
        "label": "name",
        "items": [
            { "abbr": "ec", "name": "Ecuador", "capital": "Quito" },
            { "abbr": "eg", "name": "Egypt", "capital": "Cairo" },
            { "abbr": "sv", "name": "El Salvador", "capital": "San Salvador" },
            { "abbr": "gq", "name": "Equatorial Guinea", "capital": "Malabo" },
            { "abbr": "er", "name": "Eritrea", "capital": "Asmara" },
            { "abbr": "ee", "name": "Estonia", "capital": "Tallinn" },
            { "abbr": "et", "name": "Ethiopia", "capital": "Addis Ababa" } 
        ]
    }
    

    A good place where you can validate your JSON data is http://www.jsonlint.com/.

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

Sidebar

Related Questions

I have been struggling with this all day and have tried going through the
I have been struggling all day to get data to show in a jqgrid.
I'm very new to programming in Android, but have been struggling all day with
Have been struggling all day trying to make this simple example work using socket.io.
I have been struggling with this all day (and yesterday as well). Basically, I
I've been struggling with this all day long! In the GemFile, I have: group
So I have been struggling with this one all morning. I have read a
i've been struggeling with this all day now I want to make an API
I've been struggling all day calling a Stored Procedure from a classic ASP page.
I've been struggling with Zend_Navigation all weekend, and now I have another problem, which

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.