文章内容
一、异步方式
1 2 3 4 5 | $.getJSON ( "js/userinfo.txt" , function (data) { $.each (data, function (i, item) { $ ( "#disp" ).append ( "<h3>" + item.name + "</h3>" ); }); }); |
二、同步方式
01 02 03 04 05 06 07 08 09 10 11 | $.ajax({ type: "get" , url: "demo.json" , dataType: "json" , async : false , success: function (data){ $.each (data, function (i, item) { $ ( "#disp" ).append ( "<h3>" + item.name + "</h3>" ); }); } }); |