Node.js issue with calling json data

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?

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.

Another option to go along with what Max suggested is to use res.format() to return the specific content type you want.

http://expressjs.com/api.html#res.format

res.format({
  text: function(){
      res.send(...);
  },
  html: function(){
      res.send(...);
  },
  json: function(){
    fs.readFile('./public/channels.json', 'utf8', function (err, data) {
        var channels = JSON.parse(data);
        res.send(channels);
    });
  }
});