發表文章

目前顯示的是 9月, 2010的文章

Sample of Get JSON to Table

因AJAX不能跨domain取資料...所以getJSON的部分需要帶入相對位置喔~ <html> <head> <title>Parsing JSON From PHP Using jQuery</title> <script src="/HR/js/jquery/jquery-1.3.2.min.js" type="text/javascript"> </script> </head> <body> <a href="#" id="loaduserdata">User Data</a> <table id="userdata" border="1"> <thead> <th>First Name</th> <th>Last Name</th> </thead> <tbody></tbody> </table> <script> $(document).ready(function(){ }); $("#loaduserdata").click(function(){ $("#userdata tbody").html(""); $.getJSON( "/HR/JsonRequest?event=8", function(data){ $.each(data.items, function(i,n){ var tblRow = "<tr>" +"<td>"+n.mkey+"</td>" +"<td>"+n.mvalue+"</td>"