F
F
frees22014-10-13 11:38:48
JavaScript
frees2, 2014-10-13 11:38:48

How to correctly load multiple JSON from a file?

First received the file by

$.ajax({
        type: 'POST',
        dataType:'json',
        url: 'tab.json',

...
After testing, I realized that the data placed in the script itself "works faster" than in a separate large tab.json file.
However, can anyone advise how to organize loading from a separate .json text file of each block (var habrahabr) ( var google) and so on.
I would like to reduce the size of the script itself. Or is it not correct?
$(document).ready(function(){
var habrahabr = [
{d: "google", sd: "http://toster.ru/rss/tag_questions/7?ss=1", style:"background: #F6D3D3;" },
 {d: "hubs", sd: "http://habrahabr.ru/rss/hubs/?q=1", style:"background: #999900;" }];

var google = [ 
 {d: "xakep ru", sd: "http://www.xakep.ru/articles/rss/default.asp?ss=1", style:"background: #CCBFBF;" },
  {d: "Science", sd: "http://gdata.youtube.com/feeds/api/videos?category=Science%7CTechnology&time=today", style:"background:#D3EDF6;" } ];

...
PS / So I understand (type: 'POST', dataType: 'json',) this is outdated, you can do it differently.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey, 2014-10-13
Protko @Fesor

The code you provided is never json, it's regular js, include it as a script if you want, and it's not clear why you're picking it up via POST. It is also not clear why it is wrapped in document.ready.

F
frees2, 2014-10-13
@frees2

document.ready, there is a function, processing, it doesn't matter.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question