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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:03:12+00:00 2026-06-14T22:03:12+00:00

I have this JSON file I generate in the server I want to make

  • 0

I have this JSON file I generate in the server I want to make accessible on the client as the page is viewable. Basically what I want to achieve is:

I have the following tag declared in my html document:

<script id="test" type="application/json" src="http://myresources/stuf.json">

The file referred in its source has JSON data. As I’ve seen, data has been downloaded, just like it happens with the scripts.

Now, how do I access it in Javascript? I’ve tried accessing the script tag, with and without jQuery, using a multitude of methods to try to get my JSON data, but somehow this doesn’t work. Getting its innerHTML would have worked had the json data been written inline in the script. Which it wasn’t and isn’t what I’m trying to achieve.

Remote JSON Request after page loads is also not an option, in case you want to suggest that.

  • 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-14T22:03:14+00:00Added an answer on June 14, 2026 at 10:03 pm

    You can’t load JSON like that, sorry.

    I know you’re thinking “why I can’t I just use src here? I’ve seen stuff like this…”:

    <script id="myJson" type="application/json">
     { 
       name: 'Foo' 
     }
    </script>
    
    <script type="text/javascript">
        $(function() {
            var x = JSON.parse($('#myJson').html());
            alert(x.name); //Foo
         });
    </script>
    

    … well to put it simply, that was just the script tag being “abused” as a data holder. You can do that with all sorts of data. For example, a lot of templating engines leverage script tags to hold templates.

    You have a short list of options to load your JSON from a remote file:

    1. Use $.get('your.json') or some other such AJAX method.
    2. Write a file that sets a global variable to your json. (seems hokey).
    3. Pull it into an invisible iframe, then scrape the contents of that after it’s loaded (I call this “1997 mode”)
    4. Consult a voodoo priest.

    Final point:

    Remote JSON Request after page loads is also not an option, in case you want to suggest that.

    … that doesn’t make sense. The difference between an AJAX request and a request sent by the browser while processing your <script src=""> is essentially nothing. They’ll both be doing a GET on the resource. HTTP doesn’t care if it’s done because of a script tag or an AJAX call, and neither will your server.

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

Sidebar

Related Questions

I have a JSON file which contains a pound symbol in it. This json
I have this swf (flash) file that provides the json that needs to be
I have a json file exported from phpmyadmin, it looks like this(utf-8 file): [{user_email:
I have some data and need to create a json file with this structure
i have this JSON object: {error:null, result:[{id:1234567890, count:1, recipients: [u3848, u8958, u7477474 ], dateCreated:2012-06-13T09:13:45.989Z
I have this JSON http://www.progmic.com/ielts/retrive.php that I need to parse. When I do it
I have this JSON (which validates according to JSONLint ): [ { "BugCount":"2", "BugTitle":"C:\\INETPUB\\WWWROOT\\CLUBREADY2\\TRAINERS\\../Connections/LTC.asp",
I have this json object : { msg_id:134, message:Dick, comment:[ { com_id:9, comment:test, msg_id:134,
I have this JSON response string: {d:{\ID_usuario\:\000130\,\Nombre\:null,\Vipxlo\:0,\Provmun\:null,\Descuentos\:null,\Listaviplocal\:null}}` With this code: - (void)connectionDidFinishLoading:(NSURLConnection *)connection {
I have a JSON data file that is part of my application (version controlled,

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.