Shawn31313
Shawn31313

Reputation: 6052

My "JSON" isn't working

I'm loading a large number of items on a page through JSON, but it isn't working. This is my first time using JSON and I figured JSON was just a big object so I copied my object that I had before in a variable into a file and names it fun.js.

You can check out the JSON here:

http://justpaste.it/15zc

I'm using jQuery to get the JSON:

$.getJSON('fun.js', function(data){
alert(data)
});

Nothing is being alert, in the matter of fact...the alert isn't happening at all. Anyone know why?

Upvotes: 0

Views: 3843

Answers (2)

Brian Nickel
Brian Nickel

Reputation: 27550

Have you validated that the JSON is the issue? Open up Firebug or Chrome Dev Tools and refresh the page. You may see a message that the file wasn't found or there was a parsing exception or a security error.

  • If the file isn't found, you can fix that in the code.
  • If there is a parsing error, use a JSON validator.
  • If there is a security issue, see my answer to Get a JSON file from URL and display. You need to update your server policy or configure your browser to allow access to file URL's in your tests through.

Upvotes: 0

Jure C.
Jure C.

Reputation: 3080

For starters, your JSON doesnt validate. Go paste it here and fix your errors: http://jsonformatter.curiousconcept.com/

Secondly, user jQuery.Ajax to which you can pass onError parameter so you'll get a warning that JSON didn't go through.

Upvotes: 5

Related Questions