{"id":1043,"date":"2011-07-28T03:17:54","date_gmt":"2011-07-27T18:17:54","guid":{"rendered":"http:\/\/codaholic.org\/?p=1043"},"modified":"2011-07-28T03:17:54","modified_gmt":"2011-07-27T18:17:54","slug":"jqueryajax%e3%83%a1%e3%82%bd%e3%83%83%e3%83%89%e3%82%92%e3%83%ab%e3%83%bc%e3%83%97%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6%e7%b9%b0%e3%82%8a%e8%bf%94%e3%81%99%e5%a0%b4%e5%90%88%e3%81%afeach%e3%82%92","status":"publish","type":"post","link":"https:\/\/codaholic.org\/?p=1043","title":{"rendered":"[jQuery]ajax\u30e1\u30bd\u30c3\u30c9\u3092\u30eb\u30fc\u30d7\u3092\u4f7f\u3063\u3066\u7e70\u308a\u8fd4\u3059\u5834\u5408\u306feach\u3092\u4f7f\u3046\u3068\u3046\u307e\u304f\u3044\u304f"},"content":{"rendered":"<p>jQuery\u306eajax\u30e1\u30bd\u30c3\u30c9\u3092for\u3067\u7e70\u308a\u8fd4\u3057\u5b9f\u884c\u3057\u305f\u6642\u306b\u671f\u5f85\u3057\u305f\u7d50\u679c\u304c\u5f97\u3089\u308c\u307e\u305b\u3093\u3067\u3057\u305f\u3002\u3053\u308c\u306f\u975e\u540c\u671f\u3067\u5b9f\u884c\u3055\u308c\u3066\u3044\u308b\u304c\u305f\u3081\u306e\u6319\u52d5\u3060\u3068\u601d\u3044\u307e\u3059\u304c\u3001\u8a73\u7d30\u306f\u4eca\u306e\u3068\u3053\u308d\u8abf\u67fb\u4e2d\u3067\u3059\u3002for\u3067\u30eb\u30fc\u30d7\u3055\u305b\u308b\u3053\u3068\u306f\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f\u304c\u3001each\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u3046\u3053\u3068\u3067\u6b63\u3057\u304f\u52d5\u304f\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002\u52d5\u304b\u306a\u3044\u30b3\u30fc\u30c9\u3068\u52d5\u304f\u30b3\u30fc\u30c9\u3092\u793a\u3057\u307e\u3059\u3002<\/p>\n<p><!--more--><\/p>\n<p>\u307e\u305a\u3001ajax\u306e\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u53d7\u3051\u4ed8\u3051\u308bPHP\u3067\u3059\u3002Twitter API\u3092\u4f7f\u3063\u3066\u4e0e\u3048\u3089\u308c\u305f\u30d1\u30e9\u30e1\u30fc\u30bf\u306eTwitter ID\u306e\u30d5\u30a9\u30ed\u30fc\u6570\u3068\u30d5\u30a9\u30ed\u30ef\u30fc\u6570\u3092\u53d6\u5f97\u3057\u3066json\u3067\u51fa\u529b\u3057\u307e\u3059\u3002<\/p>\n<p>get_twitter_status.php<br \/>\n[php]<br \/>\n<?php\n\t$id = htmlspecialchars($_GET['id'], ENT_QUOTES, 'UTF-8');\n\t$url = 'http:\/\/api.twitter.com\/1\/statuses\/user_timeline.xml?id=' . $id;\n\t$response = @file_get_contents($url);\n\t$xml = simplexml_load_string($response);\n\t$json = '{';\n\t$json .= '\"following\": \"' . $xml->status->user->friends_count . &#8216;&#8221;,&#8217;;<br \/>\n\t$json .= &#8216;&#8221;followed&#8221;: &#8220;&#8216; . $xml->status->user->followers_count . &#8216;&#8221;&#8216;;<br \/>\n\t$json .= &#8216;}&#8217;;<br \/>\n\tprint $json;<br \/>\n?><br \/>\n[\/php]<br \/>\n<br \/>\n\u4e0b\u8a18\u306fajax\u3092\u4f7f\u3063\u3066\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u884c\u3046\u30b9\u30af\u30ea\u30d7\u30c8\u3067\u3059\u3002\u6700\u521d\u306b\u53d6\u5f97\u3057\u305f\u3044Twitter ID\u3092\u914d\u5217\u306b\u683c\u7d0d\u3057\u3066\u3001\u683c\u7d0d\u3055\u308c\u305fID\u306e\u6570\u3060\u3051\u30ea\u30af\u30a8\u30b9\u30c8\u3092\u884c\u3046\u3088\u3046\u306b\u3057\u307e\u3057\u305f\u3002\u305d\u3057\u3066\u30ec\u30b9\u30dd\u30f3\u30b9\u3092Twitter ID\u3068\u4e00\u81f4\u3059\u308bid\u304c\u8a2d\u5b9a\u3055\u308c\u305fdiv\u8981\u7d20\u306bappend\u3057\u307e\u3059\u30021\u3064\u76ee\u306efor\u3067\u30eb\u30fc\u30d7\u3092\u3057\u3066\u3044\u308b\u3082\u306e\u306f\u6b63\u3057\u304f\u7d50\u679c\u304c\u8868\u793a\u3055\u308c\u307e\u305b\u3093\u3002<\/p>\n<p>index.html (\u52d5\u304b\u306a\u3044\u3082\u306e)<br \/>\n[html]<br \/>\n<html><br \/>\n\t<head><br \/>\n\t\t<meta charset=\"UTF-8\" \/><br \/>\n\t\t<script type=\"text\/javascript\" src=\"http:\/\/ajax.googleapis.com\/ajax\/libs\/jquery\/1.6.2\/jquery.min.js\"><\/script><br \/>\n\t\t<script type=\"text\/javascript\">\n\t\t\t$(function(){\n\t\t\t\tvar targetId = ['matome_navi', 'shoei_onedari', 'remaining_days'];\n\t\t\t\tvar i;<\/p>\n<p>\t\t\t\tfor(i = 0; i < targetId.length; i++){\n\t\t\t\t\t$.ajax({\n\t\t\t\t\t\t'type': 'get',\n\t\t\t\t\t\t'url': 'get_twitter_status.php',\n\t\t\t\t\t\t'data': {\n\t\t\t\t\t\t\t'id': targetId[i]\n\t\t\t\t\t\t},\n\t\t\t\t\t\t'success': function(data){\n\t\t\t\t\t\t\tvar status = eval('(' + data + ')');\n\t\t\t\t\t\t\t$('#' + targetId[i]).append(status.following);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t});\n\t\t<\/script><br \/>\n\t<\/head><br \/>\n\t<body><\/p>\n<div id=\"matome_navi\"><\/div>\n<div id=\"shoei_onedari\"><\/div>\n<div id=\"remaining_days\"><\/div>\n<p>\t<\/body><br \/>\n<\/html><br \/>\n[\/html]<br \/>\n<br \/>\n\u4e0b\u8a18\u306ffor\u3092each\u30e1\u30bd\u30c3\u30c9\u306b\u5909\u3048\u305f\u3082\u306e\u3067\u3059\u3002\u3053\u3061\u3089\u306f\u610f\u56f3\u3057\u3066\u3044\u305f\u901a\u308a\u306e\u52d5\u304d\u3092\u3057\u307e\u3059\u3002<\/p>\n<p>index.html (\u52d5\u304f\u3082\u306e)<br \/>\n[html]<br \/>\n<html><br \/>\n\t<head><br \/>\n\t\t<meta charset=\"UTF-8\" \/><br \/>\n\t\t<script type=\"text\/javascript\" src=\"http:\/\/ajax.googleapis.com\/ajax\/libs\/jquery\/1.6.2\/jquery.min.js\"><\/script><br \/>\n\t\t<script type=\"text\/javascript\">\n\t\t\t$(function(){\n\t\t\t\t$.each(targetId, function(i){\n\t\t\t\t\t$.ajax({\n\t\t\t\t\t\t'type': 'get',\n\t\t\t\t\t\t'url': 'get_twitter_status.php',\n\t\t\t\t\t\t'data': {\n\t\t\t\t\t\t\t'id': targetId[i]\n\t\t\t\t\t\t},\n\t\t\t\t\t\t'success': function(data){\n\t\t\t\t\t\t\tvar status = eval('(' + data + ')');\n\t\t\t\t\t\t\t$('#' + targetId[i]).append(status.following);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t});\n\t\t<\/script><br \/>\n\t<\/head><br \/>\n\t<body><\/p>\n<div id=\"matome_navi\"><\/div>\n<div id=\"shoei_onedari\"><\/div>\n<div id=\"remaining_days\"><\/div>\n<p>\t<\/body><br \/>\n<\/html><br \/>\n[\/html]<br \/>\n<br \/>\n\u975e\u540c\u671f\u3067\u3042\u308b\u3053\u3068\u3068API\u3092\u4f7f\u3063\u3066\u3044\u308b\u306e\u3067\u30ec\u30b9\u30dd\u30f3\u30b9\u3092\u53d7\u3051\u53d6\u308b\u307e\u3067\u306b\u9045\u5ef6\u304c\u3042\u308b\u3053\u3068\u304c\u539f\u56e0\u3060\u3068\u63a8\u6e2c\u3057\u3066\u3044\u307e\u3059\u304c\u3001jQuery\u306eeach\u30e1\u30bd\u30c3\u30c9\u304c\u305d\u306e\u3042\u305f\u308a\u3092\u5438\u53ce\u3057\u3066\u304f\u308c\u3066\u3044\u308b\u306e\u3067\u3057\u3087\u3046\u304b\u3002\u540c\u3058\u3088\u3046\u306a\u73fe\u8c61\u306b\u3072\u3063\u304b\u304b\u3063\u305f\u65b9\u306feach\u30e1\u30bd\u30c3\u30c9\u3092\u304a\u8a66\u3057\u304f\u3060\u3055\u3044\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>jQuery\u306eajax\u30e1\u30bd\u30c3\u30c9\u3092for\u3067\u7e70\u308a\u8fd4\u3057\u5b9f\u884c\u3057\u305f\u6642\u306b\u671f\u5f85\u3057\u305f\u7d50\u679c\u304c\u5f97\u3089\u308c\u307e\u305b\u3093\u3067\u3057\u305f\u3002\u3053\u308c\u306f\u975e\u540c\u671f\u3067\u5b9f\u884c\u3055\u308c\u3066\u3044\u308b\u304c\u305f\u3081\u306e\u6319\u52d5\u3060\u3068\u601d\u3044\u307e\u3059\u304c\u3001\u8a73\u7d30\u306f\u4eca\u306e\u3068\u3053\u308d\u8abf\u67fb\u4e2d\u3067\u3059\u3002for\u3067\u30eb\u30fc\u30d7\u3055\u305b\u308b\u3053\u3068\u306f\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[39,6,4],"tags":[137,246],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8gd1W-gP","_links":{"self":[{"href":"https:\/\/codaholic.org\/index.php?rest_route=\/wp\/v2\/posts\/1043"}],"collection":[{"href":"https:\/\/codaholic.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codaholic.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codaholic.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codaholic.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1043"}],"version-history":[{"count":4,"href":"https:\/\/codaholic.org\/index.php?rest_route=\/wp\/v2\/posts\/1043\/revisions"}],"predecessor-version":[{"id":1047,"href":"https:\/\/codaholic.org\/index.php?rest_route=\/wp\/v2\/posts\/1043\/revisions\/1047"}],"wp:attachment":[{"href":"https:\/\/codaholic.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1043"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codaholic.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1043"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codaholic.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1043"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}