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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T23:55:39+00:00 2026-06-07T23:55:39+00:00

How do I load an object into javascript if it is available in a

  • 0

How do I load an object into javascript if it is available in a json file?

I have the following script in my html:

<script src='scene.json'></script>
<script>
  var x = scene.x;
</script>

And this is the file scene.json, located in the same folder:

{"scene": {
  "x": 0,
  "y": 0,
  "w": 11000,
  "h": 3500,
}}

But the json file is not loaded properly (unexpected token ‘:’) and the scene.x reference is also probably not the way it should be done. Is it possible to refer to the data directly? Or does it need to be loaded by some http request?

  • 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-07T23:55:40+00:00Added an answer on June 7, 2026 at 11:55 pm
    {"scene": {
      "x": 0,
      "y": 0,
      "w": 11000,
      "h": 3500
    }}
    

    Is invalid javascript (because it’s treated as a block), you probably just want a javascript file:

    var scene = {
      "x": 0,
      "y": 0,
      "w": 11000,
      "h": 3500
    };
    

    If you want to keep the file as JSON, you cannot reference it from a script element and have it work while being valid JSON. You would need to use ajax request to fetch the file and parse the JSON.

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

Sidebar

Related Questions

Is it possible to load an html document into a DOM javascript object so
I have entries in a text file which I want to load into a
I have an activex object I loaded into an html page. I then use
I load some images into an object list , and then try to recall
I have this: protected void Page_Load(object sender, EventArgs e) { nome_Txt.Text = Profile.dados_pessoais.nome; }
I have two pages, test1.aspx and test2.aspx test1.aspx has this protected void Page_Load(object sender,
I'm trying only to load a part of a text file (*.txt) into the
I have a Javascript function that accepts a list of HTML nodes, but it
I have a webview and I load some html5+js into it. My webapp is
My research into the base HTML DOM element says this about any DOM element's

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.