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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:16:34+00:00 2026-06-14T11:16:34+00:00

I have some issues with getting json data from a json file, first of

  • 0

I have some issues with getting json data from a json file, first of all here is the error:
"NetworkError: 404 Not Found - http://localhost:8000/channels.json"

Here is the code for getting json data in my html file:

      <div id="result"></div>
      <script type="text/javascript">
    // read episodes in channel
    function ajaxRequest(){
        if (window.XMLHttpRequest) // if Mozilla, Safari etc
            return new XMLHttpRequest();
        else
            return false;
    }

    var mygetrequest=new ajaxRequest();
    mygetrequest.onreadystatechange=function(){
        if (mygetrequest.readyState==4){
            if (mygetrequest.status==200 || window.location.href.indexOf("http")==-1){
                var jsondata=eval("("+mygetrequest.responseText+")"); //retrieve result as an JavaScript object
                var rssentries=jsondata.channels;
                var output='<ul>';
                for (var i=0; i<rssentries.length; i++){
                    output+='<li>';
                    output+=rssentries[i].channel_id+'</a><br>';
                    output+='<a href="multiroom.html">'+rssentries[i].name+'</a>';
                    output+='</li>';
                }
                output+='</ul>';
                document.getElementById("result").innerHTML=output;
            }else{
                alert("An error has occured making the request");
            }
        }
    }

    mygetrequest.open("GET", "channels.json", true);
    mygetrequest.send(null);

    </script>

so the html works standing alone, but when i try to render it in my node server, i get error, code in my node server in express:

var express = require('express');
var http = require('http'); 
var app = express();
var server = module.exports = http.createServer(app);

server.listen(8000);
console.log("Express server listening on port 8000 in %s mode");

app.set('views', __dirname + '/views');
app.engine('html', require('ejs').renderFile);

app.get('/episodes', function(req, res){
    res.render('episodes.html');
});

So i have to do the json data call in the server in order to avoid the error, there’s no other way?

  • 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-14T11:16:36+00:00Added an answer on June 14, 2026 at 11:16 am

    If u are rendering on the server, you can’t use Ajax. Ajax only runs from within the browser, not on the server. On the server you have to read the file directly, pass it to the renderer, and render it inside of the template. For example:

    var fs = require('fs');
    app.get('/episodes', function(req, res){
        fs.readFile('./public/channels.json', 'utf8', function (err, data) {
            var channels = JSON.parse(data);
            res.render('episodes.html', channels);
        });
    });
    

    Inside your ejs template you’ll have to render the channels directly into the page.

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

Sidebar

Related Questions

I have some issues with a PHP file that is not working properly. The
I seems to have some issues in order to compile gproc from uwiger. I
Building my first SL MVVM application (Silverlight4 RC) and have some issues i don't
I'm relatively new to c++, and have some issues with ifstream. All I want
Having some issues getting this MPMoviePlayerViewController to work. I have two sample URLs pointing
I'm having some issues getting my pdf file to display in my jsp page.
I have some issues with getting my app running on my iPhone 1G 3.1.3.
I'm having some issues getting Areas working correctly within MVC 3. I have the
I'm having some issues with getting my mouse events to work. I have a
I am having some issues getting db:push to work with heroku. As I have

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.