{"id":438,"date":"2013-02-26T23:19:24","date_gmt":"2013-02-26T14:19:24","guid":{"rendered":"http:\/\/taitan916.info\/blog\/?p=438"},"modified":"2024-02-06T13:05:57","modified_gmt":"2024-02-06T04:05:57","slug":"post-438","status":"publish","type":"post","link":"https:\/\/taitan916.info\/blog\/archives\/438","title":{"rendered":"jQuery\u306b\u3066\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3059\u308b\u3068Ajax\u901a\u4fe1\u3057\u7d50\u679c\u3092\u30c6\u30ad\u30b9\u30c8\u30dc\u30c3\u30af\u30b9\u306b\u53cd\u6620\u3059\u308b\u65b9\u6cd5"},"content":{"rendered":"<p>jQuery\u3092\u5229\u7528\u3057\u30da\u30fc\u30b8\u5185\u306e\u7279\u5b9a\u306e\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3059\u308b\u3068\u3001\u6307\u5b9a\u306e\u30da\u30fc\u30b8\u306bAjax\u901a\u4fe1\u3057\u3066\u30ea\u30af\u30a8\u30b9\u30c8\u7d50\u679c\u3092\u7279\u5b9a\u306e\u30c6\u30ad\u30b9\u30c8\u30dc\u30c3\u30af\u30b9\u306evalue\u306b\u53cd\u6620\u3055\u305b\u305f\u3044\u3002\u307e\u305f\u3001Ajax\u901a\u4fe1\u3059\u308b\u30da\u30fc\u30b8\u306f\u8aad\u307f\u8fbc\u3080\u5ea6\u306b\u7570\u306a\u308b\u5185\u5bb9\u304c\u8868\u793a\u3055\u308c\u308b\u305f\u3081\u3001\u30dc\u30bf\u30f3\u3092\u62bc\u3059\u305f\u3073\u306b\u305d\u306e\u5185\u5bb9\u3092\u53cd\u6620\u3055\u305b\u305f\u3044\u3002\u4ee5\u4e0b\u306b\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3068\u30b5\u30f3\u30d7\u30eb\u3092\u30e1\u30e2\u3002<\/p>\n<p>&nbsp;<\/p>\n<h2>\u30ea\u30d5\u30a1\u30ec\u30f3\u30b9<\/h2>\n<p><a href=\"https:\/\/api.jquery.com\/jQuery.ajax\/\" target=\"_blank\" rel=\"noopener\">https:\/\/api.jquery.com\/jQuery.ajax\/<\/a><\/p>\n<p>&nbsp;<\/p>\n<h2>\u30b5\u30f3\u30d7\u30eb<\/h2>\n<p><a href=\"https:\/\/taitan916.info\/sample\/ajax\/btn_textbox\/\" target=\"_blank\" rel=\"noopener\">https:\/\/taitan916.info\/sample\/ajax\/btn_textbox\/<\/a><\/p>\n<p>&nbsp;<\/p>\n<h2>\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9<\/h2>\n<h3>Ajax\u901a\u4fe1\u306e\u7d50\u679c\u3092\u8fd4\u3059\u30da\u30fc\u30b8(ajax.php)<\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">&lt;?php\r\n$name = array('\u5c71\u7530', '\u9234\u6728', '\u4f50\u3005\u6728', '\u7530\u4e2d');\r\necho $name[array_rand($name, 1)];<\/pre>\n<p>\u300c$name\u300d\u914d\u5217\u306e\u4e2d\u304b\u3089\u30e9\u30f3\u30c0\u30e0\u30671\u3064\u306e\u5024\u3092\u8868\u793a\u3059\u308b\u5f62\u3002<\/p>\n<h3>Ajax\u901a\u4fe1\u30ea\u30af\u30a8\u30b9\u30c8\u3059\u308b\u30da\u30fc\u30b8(index.php)<\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">&lt;html lang=\"ja\"&gt;\r\n&lt;head&gt;\r\n&lt;meta http-equiv=\"Content-Type\" content=\"text\/html; charset=UTF-8\"&gt;\r\n&lt;title&gt;Ajax\u3067\u30dc\u30bf\u30f3\u3068\u30c6\u30ad\u30b9\u30c8\u30dc\u30c3\u30af\u30b9\u64cd\u4f5c\u306e\u30b5\u30f3\u30d7\u30eb&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n    &lt;input type=\"text\" id=\"name\" value=\"\"&gt;\r\n    &lt;input type=\"button\" value=\"\u30c6\u30b9\u30c8\u30dc\u30bf\u30f3\" id=\"name_change\"&gt;\r\n\r\n    &lt;script type=\"text\/javascript\" src=\"https:\/\/code.jquery.com\/jquery-3.7.1.min.js\"&gt;&lt;\/script&gt;\r\n    &lt;script type=\"text\/javascript\"&gt;\r\n    $(function(){\r\n        $(`#name_change`).click(function(){\r\n            $.ajax({\r\n                url: `.\/ajax.php?t=${$.now()}`,\r\n            }).done(function(result){\r\n                if( result ){\r\n                    $(`#name`).val(result);\r\n                }else{\r\n                    alert(`\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3057\u305f\u3002`);\r\n                }\r\n\r\n            \/\/ajax\u81ea\u4f53\u306e\u30a8\u30e9\u30fc\u6642\r\n            }).fail(function(){\r\n                alert(`\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3057\u305f\u3002`);\r\n\r\n            }).always(function(){\r\n                \/\/\u5b8c\u4e86\u5f8c\u306e\u51e6\u7406\r\n            });\r\n        });\r\n    });\r\n    &lt;\/script&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<p>\u300c.\/ajax.php?t=${$.now()}\u300d\u90e8\u5206\u306f\u30ad\u30e3\u30c3\u30b7\u30e5\u5bfe\u7b56\u3067\u30bf\u30a4\u30e0\u30b9\u30bf\u30f3\u30d7\u3092\u4ed8\u4e0e\u3057\u3066\u3044\u308b\u3002\u3053\u3053\u306f\u30b5\u30fc\u30d0(Apache\u7b49)\u306e\u30ad\u30e3\u30c3\u30b7\u30e5\u8a2d\u5b9a\u306b\u3088\u3063\u3066\u306f\u4e0d\u8981\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>jQuery\u3092\u5229\u7528\u3057\u30da\u30fc\u30b8\u5185\u306e\u7279\u5b9a\u306e\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3059\u308b\u3068\u3001\u6307\u5b9a\u306e\u30da\u30fc\u30b8\u306bAja ... <\/p>\n","protected":false},"author":1,"featured_media":1071,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[3,4],"tags":[],"class_list":["post-438","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-jquery","category-javascript"],"acf":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/posts\/438","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/comments?post=438"}],"version-history":[{"count":3,"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/posts\/438\/revisions"}],"predecessor-version":[{"id":4542,"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/posts\/438\/revisions\/4542"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/media\/1071"}],"wp:attachment":[{"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/media?parent=438"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/categories?post=438"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/tags?post=438"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}