0

I have a json file with my folder. as a sample it is like this:

json file :

{
  "name" : "testing"
}

in my view file i am trying like this:

jQuery(document).ready(function($) {

    var model = Backbone.Model.extend({});

    var view = Backbone.View.extend({
        model : model,
        initialize : function () {
            this.data = $.getJSON("OriginatingBanks.json", 
                function(data) {
                console.log(data); //data not at all loading.
            }).error(function(jqXhr, textStatus, error) {
                console.log("ERROR: " + textStatus + ", " + error);
            });
        }
    });

    var originatingBank = new view;

});

the json file sitting with html file as a sibling. what wrong goes here? any one help me?

update

While i try to open using the localhost, I am getting this error from local server:

Here is the screen shot

3gwebtrain
  • 14,640
  • 25
  • 121
  • 247
  • JavaScript in the browser can't access the system the browser is running on. –  Sep 17 '14 at 12:33
  • Look at the browser console and check the request being made. Check the address and ensure that it's correct. – Boris the Spider Sep 17 '14 at 12:33
  • 2
    @Tichodroma as of HTML5 this is now not true. Plus I the OP says _the json file sitting with html file as a sibling_ which implies the JSON is next the the HTML on the _server_. – Boris the Spider Sep 17 '14 at 12:34
  • make sure you have correctly spelled the file name and there is not small/capital case problem – A.B Sep 17 '14 at 12:37
  • @BoristheSpider So the question title talking about "local file" is contradicting the question body (as you interpret it). Close vote for unclear question cast. –  Sep 17 '14 at 12:37
  • @Tichodroma agreed, question is unclear. I would guess that the OP wants to open a _local_ html file with the browser (using the `file://` URI) and then access a `.json` file that lives in the adjacent folder. But that is just a guess and needs clarification. – Boris the Spider Sep 17 '14 at 12:39
  • Your question is ambiguous. You say "local file" in the title, and yet you say "json file sitting with html file as a sibling". And what do you mean by "view file"? Where are the files? In a server or your local machine? And how are you running it? Via browser, or Node.js, etc...? – sampathsris Sep 17 '14 at 12:41
  • I am working with `localhost`, I am trying to load the json file to my `Backbone` view function. the json file here with local folder. let me change the title then. – 3gwebtrain Sep 17 '14 at 12:46
  • Do you get anything in the console? I think you have to remove `this.data = `. Now you are only saving the function in a variable. not running it. (Also i can't any Backbone so i'm not sure!) – Andreas Furster Sep 17 '14 at 12:52
  • can you see my update.. – 3gwebtrain Sep 17 '14 at 12:54
  • Thanks to all... I go the Answer from this Question: [http://stackoverflow.com/questions/332988/get-iis6-to-serve-json-files-inc-post-get][1] [1]: http://stackoverflow.com/questions/332988/get-iis6-to-serve-json-files-inc-post-get – 3gwebtrain Sep 18 '14 at 04:44

0 Answers0