{"id":2392,"date":"2012-06-06T10:35:50","date_gmt":"2012-06-06T01:35:50","guid":{"rendered":"http:\/\/mechsys.tec.u-ryukyu.ac.jp\/~oshiro\/SiteList\/?p=2392"},"modified":"2012-06-06T21:46:41","modified_gmt":"2012-06-06T12:46:41","slug":"yoyyyeiiojqueryce","status":"publish","type":"post","link":"http:\/\/mechsys.tec.u-ryukyu.ac.jp\/~oshiro\/SiteList\/2012\/06\/06\/2392\/","title":{"rendered":"\u30d5\u30a1\u30a4\u30eb\u4e00\u89a7\u3092jQuery\u3067\u8868\u793a"},"content":{"rendered":"<p>\u753b\u50cf\u30d5\u30a1\u30a4\u30eb\u306e\u4e00\u89a7\u3092jQuery\u3067\u8868\u793a\u3055\u305b\u308b\u3002\u305d\u306e\u5bfe\u8c61\u30d5\u30a1\u30a4\u30eb\u540d\u306e\u53d6\u5f97\u81ea\u4f53\u306fJavaScript\u3067\u306f\u5bfe\u5fdc\u3067\u304d\u306a\u3044\u306e\u3067\u3001\u5225\u9014php\u306b\u4e0b\u8acb\u3051\u306b\u51fa\u3059\u5f62\u306b\u3059\u308b\u3002<\/p>\n<div class=\"hl-surround\" style=\"height:280px;\"><div class=\"hl-main\"><pre>&lt;!-- index.html --&gt;\r\n&lt;html&gt;\r\n&lt;head&gt;\r\n&lt;title&gt;Image List&lt;\/title&gt;\r\n\r\n&lt;script src=&quot;\/\/ajax.googleapis.com\/ajax\/libs\/jquery\/1.7.2\/jquery.min.js&quot;&gt;&lt;\/script&gt;\r\n\r\n&lt;style type=&quot;text\/css&quot;&gt;\r\nimg {border: none;}\r\n&lt;\/style&gt;\r\n&lt;\/head&gt;\r\n\r\n&lt;body&gt;\r\n&lt;div id=&quot;message&quot;&gt;&lt;\/div&gt;\r\n&lt;div id=&quot;image_list&quot;&gt;&lt;\/div&gt;\r\n&lt;\/body&gt;\r\n\r\n&lt;script type=&quot;text\/javascript&quot;&gt;\r\n$.getJSON(&quot;images_json.php&quot;, function(json) {\r\n  for (var i=0; i&lt;json.length; i++) {\r\n    var fname=json[i].fname;\r\n    $(&quot;#image_list&quot;).append(&quot;&lt;img src=&quot;images\/&quot;+fname+&quot;&quot; alt=&quot;&quot;+fname+&quot;&quot; title=&quot;&quot;+fname+&quot;&quot; \/&gt;&quot;);\r\n  }\r\n  $(&quot;#message&quot;).text(json.length+&quot; images.&quot;);\r\n});\r\n&lt;\/script&gt;<\/pre><\/div><\/div>\n<p>\u4e0a\u8a18\u306b\u3042\u308b\u300c$.getJSON(&#8220;\u4e0b\u8acb\u3051php\u30b9\u30af\u30ea\u30d7\u30c8&#8221;, \u30c7\u30fc\u30bf\u51e6\u7406\u95a2\u6570)\u300d\u306e\u5f62\u3067\u30c7\u30fc\u30bf\u53d6\u5f97\u3068\u8868\u793a\u3002<\/p>\n<p>\u3067\u3001\u30d5\u30a1\u30a4\u30eb\u30ea\u30b9\u30c8\u3092\u751f\u6210\u3059\u308b\u4e0b\u8acb\u3051\u5074\u306ephp\u30b9\u30af\u30ea\u30d7\u30c8\uff08\u30d5\u30a1\u30a4\u30eb\u4e00\u89a7\u3092\u53d6\u5f97\u3059\u308b\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u6307\u5b9a\u306f\u5f15\u6570\u306a\u3069\u306b\u305b\u305a\u3001\u3068\u308a\u3042\u3048\u305a\u30b9\u30af\u30ea\u30d7\u30c8\u3078\u57cb\u3081\u8fbc\u307f\uff09\uff1a<\/p>\n<div class=\"hl-surround\" ><div class=\"hl-main\"><pre><span class=\"hl-inlinetags\">&lt;?php\r\n<\/span><span class=\"hl-comment\">\/\/ images_json.php: \u753b\u50cf\u30d5\u30a1\u30a4\u30eb\u4e00\u89a7\u3092\u53d6\u5f97\u3057JSON\u5f62\u5f0f\u3067\u6e21\u3059\r\n\r\n<\/span><span class=\"hl-reserved\">if <\/span><span class=\"hl-brackets\">(<\/span><span class=\"hl-var\">$handle<\/span><span class=\"hl-code\">=<\/span><span class=\"hl-identifier\">opendir<\/span><span class=\"hl-brackets\">(<\/span><span class=\"hl-quotes\">&quot;<\/span><span class=\"hl-string\">\/fullpath\/images\/<\/span><span class=\"hl-quotes\">&quot;<\/span><span class=\"hl-brackets\">)) {\r\n    <\/span><span class=\"hl-var\">$files<\/span><span class=\"hl-code\">=<\/span><span class=\"hl-reserved\">array<\/span><span class=\"hl-brackets\">()<\/span><span class=\"hl-code\">;\r\n    <\/span><span class=\"hl-reserved\">while <\/span><span class=\"hl-brackets\">((<\/span><span class=\"hl-var\">$fname<\/span><span class=\"hl-code\"> = <\/span><span class=\"hl-identifier\">readdir<\/span><span class=\"hl-brackets\">(<\/span><span class=\"hl-var\">$handle<\/span><span class=\"hl-brackets\">))<\/span><span class=\"hl-code\">!==<\/span><span class=\"hl-reserved\">false<\/span><span class=\"hl-brackets\">) {\r\n        <\/span><span class=\"hl-reserved\">if <\/span><span class=\"hl-brackets\">(<\/span><span class=\"hl-code\">!<\/span><span class=\"hl-identifier\">preg_match<\/span><span class=\"hl-brackets\">(<\/span><span class=\"hl-quotes\">'<\/span><span class=\"hl-string\">\/.(jpe?g|gif|png|bmp|tiff?)$\/i<\/span><span class=\"hl-quotes\">'<\/span><span class=\"hl-code\">, <\/span><span class=\"hl-var\">$fname<\/span><span class=\"hl-brackets\">)) <\/span><span class=\"hl-reserved\">continue<\/span><span class=\"hl-code\">;\r\n        <\/span><span class=\"hl-identifier\">array_push<\/span><span class=\"hl-brackets\">(<\/span><span class=\"hl-var\">$files<\/span><span class=\"hl-code\">, <\/span><span class=\"hl-reserved\">array<\/span><span class=\"hl-brackets\">(<\/span><span class=\"hl-quotes\">'<\/span><span class=\"hl-string\">fname<\/span><span class=\"hl-quotes\">'<\/span><span class=\"hl-code\">=&gt;<\/span><span class=\"hl-var\">$fname<\/span><span class=\"hl-brackets\">))<\/span><span class=\"hl-code\">;\r\n    <\/span><span class=\"hl-brackets\">}\r\n    <\/span><span class=\"hl-identifier\">closedir<\/span><span class=\"hl-brackets\">(<\/span><span class=\"hl-var\">$handle<\/span><span class=\"hl-brackets\">)<\/span><span class=\"hl-code\">;\r\n\r\n    <\/span><span class=\"hl-identifier\">print json_encode<\/span><span class=\"hl-brackets\">(<\/span><span class=\"hl-var\">$files<\/span><span class=\"hl-brackets\">)<\/span><span class=\"hl-code\">;\r\n<\/span><span class=\"hl-brackets\">}\r\n<\/span><span class=\"hl-inlinetags\">?&gt;<\/span><\/pre><\/div><\/div>\n<p>JSON\u5f62\u5f0f\u306e\u751f\u6210\u306f\u3001\u300c\u30ad\u30fc=>\u5024\u300d\u306e\u5f62\u3067\u9023\u60f3\u914d\u5217\u306b\u3057\u3001\u305d\u308c\u3092\u4e00\u3064\u305a\u3064array_push\u3067\u7d0d\u3081\u3066\u3044\u3063\u3066\u3001\u305d\u306e\u914d\u5217\u3092json_encode()\u306b\u639b\u3051\u308c\u3070\u6b21\u306e\u3088\u3046\u306a\u30c7\u30fc\u30bf\u3068\u306a\u308b\uff1a<\/p>\n<div class=\"hl-surround\" ><div class=\"hl-main\"><pre><span class=\"hl-brackets\">[\r\n  {<\/span><span class=\"hl-quotes\">&quot;<\/span><span class=\"hl-string\">fname<\/span><span class=\"hl-quotes\">&quot;<\/span><span class=\"hl-code\">:<\/span><span class=\"hl-quotes\">&quot;<\/span><span class=\"hl-string\">CIMG2782.JPG<\/span><span class=\"hl-quotes\">&quot;<\/span><span class=\"hl-brackets\">}<\/span><span class=\"hl-code\">,\r\n  <\/span><span class=\"hl-brackets\">{<\/span><span class=\"hl-quotes\">&quot;<\/span><span class=\"hl-string\">fname<\/span><span class=\"hl-quotes\">&quot;<\/span><span class=\"hl-code\">:<\/span><span class=\"hl-quotes\">&quot;<\/span><span class=\"hl-string\">CIMG2780.JPG<\/span><span class=\"hl-quotes\">&quot;<\/span><span class=\"hl-brackets\">}<\/span><span class=\"hl-code\">,\r\n  <\/span><span class=\"hl-brackets\">{<\/span><span class=\"hl-quotes\">&quot;<\/span><span class=\"hl-string\">fname<\/span><span class=\"hl-quotes\">&quot;<\/span><span class=\"hl-code\">:<\/span><span class=\"hl-quotes\">&quot;<\/span><span class=\"hl-string\">CIMG2785.JPG<\/span><span class=\"hl-quotes\">&quot;<\/span><span class=\"hl-brackets\">}<\/span><span class=\"hl-code\">,\r\n    ...\r\n<\/span><span class=\"hl-brackets\">]<\/span><\/pre><\/div><\/div>\n<p><strong>\u53c2\u8003\u30ea\u30f3\u30af\uff1a<\/strong><\/p>\n<ul>\n<li><a href=\"http:\/\/d.hatena.ne.jp\/cos31\/20071112\/1194898338\">\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u5185\u306e\u30d5\u30a1\u30a4\u30eb\u4e00\u89a7\u3092\u53d6\u5f97\u3059\u308b &#8211; Affirmative Way<br \/>\n<\/a><\/p>\n<li><a href=\"http:\/\/www.php.net\/manual\/ja\/function.json-encode.php\">PHP: json_encode &#8211; Manual<br \/>\n<\/a><\/p>\n<li><a href=\"http:\/\/stackoverflow.com\/questions\/758594\/load-list-of-image-from-folder\">php &#8211; Load list of image from folder &#8211; Stack Overflow<br \/>\n<\/a>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u753b\u50cf\u30d5\u30a1\u30a4\u30eb\u306e\u4e00\u89a7\u3092jQuery\u3067\u8868\u793a\u3055\u305b\u308b\u3002\u305d\u306e\u5bfe\u8c61\u30d5\u30a1\u30a4\u30eb\u540d\u306e\u53d6\u5f97\u81ea\u4f53\u306fJavaScript\u3067\u306f\u5bfe\u5fdc\u3067\u304d\u306a\u3044\u306e\u3067\u3001\u5225\u9014php\u306b\u4e0b\u8acb\u3051\u306b\u51fa\u3059\u5f62\u306b\u3059\u308b\u3002 &lt;!&#8211; index.html &#8211;&gt; &lt;htm [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[1],"tags":[294,266,295,60],"_links":{"self":[{"href":"http:\/\/mechsys.tec.u-ryukyu.ac.jp\/~oshiro\/SiteList\/wp-json\/wp\/v2\/posts\/2392"}],"collection":[{"href":"http:\/\/mechsys.tec.u-ryukyu.ac.jp\/~oshiro\/SiteList\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/mechsys.tec.u-ryukyu.ac.jp\/~oshiro\/SiteList\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/mechsys.tec.u-ryukyu.ac.jp\/~oshiro\/SiteList\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/mechsys.tec.u-ryukyu.ac.jp\/~oshiro\/SiteList\/wp-json\/wp\/v2\/comments?post=2392"}],"version-history":[{"count":19,"href":"http:\/\/mechsys.tec.u-ryukyu.ac.jp\/~oshiro\/SiteList\/wp-json\/wp\/v2\/posts\/2392\/revisions"}],"predecessor-version":[{"id":2410,"href":"http:\/\/mechsys.tec.u-ryukyu.ac.jp\/~oshiro\/SiteList\/wp-json\/wp\/v2\/posts\/2392\/revisions\/2410"}],"wp:attachment":[{"href":"http:\/\/mechsys.tec.u-ryukyu.ac.jp\/~oshiro\/SiteList\/wp-json\/wp\/v2\/media?parent=2392"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/mechsys.tec.u-ryukyu.ac.jp\/~oshiro\/SiteList\/wp-json\/wp\/v2\/categories?post=2392"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/mechsys.tec.u-ryukyu.ac.jp\/~oshiro\/SiteList\/wp-json\/wp\/v2\/tags?post=2392"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}