How can I get javascript to read from a .json file?

前端 未结 5 1747
-上瘾入骨i
-上瘾入骨i 2020-12-01 00:48

My script currently looks like this:



        
5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-01 01:27

    You can do it like... Just give the proper path of your json file...

    
    
        
            
                 
        
        
        

    Simply getting the data and appending it to a div... Initially printing the length in alert.

    Here is my Json file: abc.json

    data = '[{"name" : "Riyaz"},{"name" : "Javed"},{"name" : "Arun"},{"name" : "Sunil"},{"name" : "Rahul"},{"name" : "Anita"}]';
    

提交回复
热议问题