How can I link external json file in JSFiddle?

后端 未结 6 1444
北荒
北荒 2021-02-06 07:33
  • I have a very long .json file country.json.

[
  {
    "name": "WORLD",
    "population": 6916183000         


        
6条回答
  •  伪装坚强ぢ
    2021-02-06 08:19

    You can actually use a locally created json, in the jsfiddle documentation:

    new Request.JSON({
        url: '/echo/json/',
        data: {
            json: JSON.encode({
                text: 'some text',
                array: [1, 2, 'three'],
                object: {
                    par1: 'another text',
                    par2: [3, 2, 'one'],
                    par3: {}
                }
            }),
            delay: 3
        },
        onSuccess: function(response) {
            show_response(response, $('post'));
        }
    }).send();
    
    show_response = function(obj, result) {
        $H(obj).each(function(v, k) {
            new Element('li', {
                text: k + ': ' + v
            }).inject(result);
        });
        result.highlight();
    };
    

    Edit1

    It's not my code, it's their fiddle anyway ;) Here:

    http://jsfiddle.net/zalun/QsHw4/light/

    Edit2

    How do use your code with my code ?

    Alright, you can actually use their code instead, since your goal is to use jsfiddle. Here's one with part of your json:

    http://jsfiddle.net/QsHw4/6348/

    I turned the ul into a table like this:

    Country Population
    Lalaland 0

    Here's the fiddle with Mr. Polywhirl CSS table ;P

    http://jsfiddle.net/QsHw4/6351/

提交回复
热议问题