{"id":2133,"date":"2017-09-11T10:00:09","date_gmt":"2017-09-11T01:00:09","guid":{"rendered":"http:\/\/alaki.co.jp\/blog\/?p=2133"},"modified":"2022-12-03T08:58:20","modified_gmt":"2022-12-02T23:58:20","slug":"ajax%e5%87%a6%e7%90%86%e3%82%92%e5%ae%9f%e8%a3%85%e3%81%97%e3%82%88%e3%81%86%ef%bc%81%ef%bc%88%e3%83%95%e3%83%ad%e3%83%b3%e3%83%88%e3%82%a8%e3%83%b3%e3%83%89%e7%b7%a8%ef%bc%89","status":"publish","type":"post","link":"http:\/\/test.alaki.co.jp\/blog\/?p=2133","title":{"rendered":"Ajax\u51e6\u7406\u3092\u5b9f\u88c5\u3057\u3088\u3046\uff01\uff08\u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u7de8\uff09"},"content":{"rendered":"<p><strong>\u3053\u3093\u306b\u3061\u306f\u3001Web\u30d7\u30ed\u30b0\u30e9\u30de\u306e\u7be0\u7530\u3067\u3059\u3002<\/strong><\/p>\n<p>\u5927\u962a\u3067\u306f\u307e\u3060\u6b8b\u6691\u304c\u6b8b\u308a\u3001\u65e5\u4e2d\u306f\u6691\u3044\u65e5\u304c\u7d9a\u3044\u3066\u3044\u307e\u3059\u304c\u3001\u671d\u3068\u5915\u65b9\u306f\u3060\u3044\u3076\u6dbc\u3057\u304f\u306a\u308a\u3001\u79cb\u306e\u6c17\u914d\u304c\u65e5\u306b\u65e5\u306b\u5897\u3057\u3066\u3044\u308b\u306e\u3092\u611f\u3058\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<p>\u4eca\u56de\u306f\u3001\u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u5074\u306e\u958b\u767a\u3067\u306f\u5229\u7528\u3092\u907f\u3051\u308b\u3053\u3068\u304c\u3067\u304d\u306a\u304f\u306a\u3063\u305f\u3001Ajax\uff08\u30a8\u30a4\u30b8\u30e3\u30c3\u30af\u30b9\uff09\u51e6\u7406\u3092\u3054\u7d39\u4ecb\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<p><!--more--><\/p>\n<h2>Ajax\u3068\u306f<\/h2>\n<p>Web\u306e\u30c7\u30fc\u30bf\u901a\u4fe1\u306f\u3001\u30d6\u30e9\u30a6\u30b6\u4e0a\u306b\u8868\u793a\u3055\u308c\u305f\u300c\u30dc\u30bf\u30f3\u300d\u3092\u30af\u30ea\u30c3\u30af\u3057\u3066\u3001\u300c\u753b\u9762\u79fb\u52d5\uff08URL\u304c\u5909\u308f\u308b\u72b6\u614b\uff09\u300d\u3092\u3059\u308b\u3053\u3068\u3067\u3001\u6b21\u306e\u51e6\u7406\u306b\u30c7\u30fc\u30bf\u3092\u6e21\u3059\u3068\u3044\u3046\u306e\u304c\u4e00\u822c\u7684\u3067\u3057\u305f\u3002<\/p>\n<p>\u3067\u3059\u304c\u3001\u300c\u753b\u9762\u79fb\u52d5\u300d\u7279\u6709\u306e\u30c1\u30e9\u30c4\u30ad\u3084\u8aad\u307f\u8fbc\u307f\u306e\u9045\u3055\u306a\u3069\u3001\u30e6\u30fc\u30b6\u30fc\u306e\u4f53\u9a13\u3092\u640d\u306a\u3046\u8981\u7d20\u304c\u591a\u304f\u3042\u308a\u307e\u3057\u305f\u3002<br \/>\n\u203b\u3053\u306e\u51e6\u7406\u3092\u300c\u540c\u671f\u51e6\u7406\u300d\u3068\u3044\u3044\u307e\u3059\u3002<\/p>\n<p>\u305d\u3053\u3067\u3001\u300c\u753b\u9762\u79fb\u52d5\u300d\u3092\u5c11\u306a\u304f\u3057\u3066\u3001\uff11\u3064\u306e\u753b\u9762\u3067\u300c\u767b\u9332\u300d\u3084\u300c\u691c\u7d22\u300d\u306a\u3069\u306e\u51e6\u7406\uff08\u30b5\u30fc\u30d0\u30fc\u9593\u306e\u901a\u4fe1\uff09\u3092\u884c\u3048\u308b\u3088\u3046\u306b\u3057\u3066\u3001\u30b9\u30e0\u30fc\u30ba\u306b\u64cd\u4f5c\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u305f\u51e6\u7406\u65b9\u6cd5\u304c\u51fa\u3066\u304d\u307e\u3057\u305f\u3002<br \/>\n\u203b\u3053\u306e\u51e6\u7406\u3092\u300c\u975e\u540c\u671f\u51e6\u7406\u300d\u3068\u3044\u3044\u307e\u3059\u3002<\/p>\n<p>\u305d\u306e\u300c\u975e\u540c\u671f\u51e6\u7406\u300d\u3092\u5b9f\u73fe\u3059\u308b\u305f\u3081\u306b\u5229\u7528\u3059\u308b\u306e\u304c\u300cJavaScript\u300d\u3068\u300cXML\u300d\u3067\u3057\u305f\u3002<\/p>\n<h2>jQuery\u3092\u4f7f\u3063\u305fAjax\u51e6\u7406<\/h2>\n<p>\u5177\u4f53\u7684\u306b\u3069\u306e\u3088\u3046\u306b\u3057\u3066\u3001\u300c\u975e\u540c\u671f\u51e6\u7406\u300d\u3092\u5b9f\u73fe\u3059\u308b\u306e\u304b\u3092\u3054\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n<p>\u6700\u3082\u5206\u304b\u308a\u3084\u3059\u3044\u624b\u9806\u3068\u3057\u3066\u300cjQuery\u300d\u3092\u5229\u7528\u3057\u305f\u300cAjax\u51e6\u7406\u300d\u3092\u898b\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"lang:js decode:true \">$.ajax({\r\n\tasync: true,\/\/ \u975e\u540c\u671f\u51e6\u7406\r\n\turl: 'http:\/\/localhost\/getName.php',\r\n\ttype: \"POST\",\r\n\tdataType: 'json',\r\n\tdata: {\r\n\t\t''user_id': 21\r\n\t}\r\n}).done(function (data) {\r\n\tconsole.log(data.name + \"\u3092\u53d6\u5f97\u3057\u307e\u3057\u305f\u3002\");\r\n}).fail(function () {\r\n\tconsole.log(\"\u51e6\u7406\u306b\u5931\u6557\u3057\u307e\u3057\u305f\u3002\");\r\n});<\/pre>\n<p>\u203b\u4e8b\u524d\u306b\u300cjQuery\u300d\u306e\u8aad\u307f\u8fbc\u307f\u3092\u884c\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u51e6\u7406\u306f\u3001\u300c\u540d\u524d\u3092Ajax\u3092\u4f7f\u3063\u3066\u53d6\u5f97\u3059\u308b\u300d\u7c21\u6613\u306a\u30d7\u30ed\u30b0\u30e9\u30e0\u3067\u3059\u3002<\/p>\n<p>\u5404\u8981\u7d20\u306e\u4f7f\u3044\u65b9\u3092\u898b\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<h3>\u540c\u671f\uff1f\u305d\u308c\u3068\u3082\u975e\u540c\u671f\uff1f<\/h3>\n<p>\u300casync\uff08\u30a8\u30a4\u30b7\u30f3\u30af\uff09\u300d\u30aa\u30d7\u30b7\u30e7\u30f3\u3067\u3001\u300c\u975e\u540c\u671f\uff08\u30c7\u30fc\u30bf\u304c\u623b\u3063\u3066\u304f\u308b\u306e\u3092\u5f85\u305f\u306a\u3044\uff09\u300d\u3067\u30c7\u30fc\u30bf\u901a\u4fe1\u3092\u884c\u3046\u304b\u3001\u300c\u540c\u671f\uff08\u30c7\u30fc\u30bf\u304c\u623b\u3063\u3066\u304f\u308b\u307e\u3067\u5f85\u3064\uff09\u300d\u304b\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<p>\u521d\u671f\u5024\u306f\u300c\u975e\u540c\u671f\u300d\u306e\u305f\u3081\u300casync: true\u300d\u3067\u3059\u3002<\/p>\n<p>\u300c\u540c\u671f\u51e6\u7406\u300d\u3092\u3059\u308b\u5834\u5408\u306f\u300casync: false\u300d\u3068\u3057\u307e\u3059\u3002<\/p>\n<p>\u3044\u3063\u305f\u3044\u3001\u3069\u3046\u3044\u3063\u305f\u901a\u4fe1\u51e6\u7406\u3092\u3057\u3066\u3044\u308b\u306e\u304b\u3092\u3001\u628a\u63e1\u3057\u3066\u304a\u304f\u3053\u3068\u304c\u91cd\u8981\u3067\u3059\u3002<\/p>\n<h3>POST\u3067\u9001\u308b\u304bGET\u3067\u9001\u308b\u304b\u305d\u308c\u304c\u554f\u984c<\/h3>\n<p>Web\u3067\u306e\u30c7\u30fc\u30bf\u901a\u4fe1\u306f\u300cPOST\u300d\u304b\u300cGET\u300d\u306e\uff12\u7a2e\u985e\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u300cAjax\u300d\u3067\u3082\u540c\u3058\u3088\u3046\u306b\u3001\u3069\u3046\u3044\u3063\u305f\u901a\u4fe1\u65b9\u6cd5\u3067\u3001\u30c7\u30fc\u30bf\u3092\u9001\u308b\u306e\u304b\u3068\u3044\u3046\u306e\u3092\u6c7a\u3081\u307e\u3059\u3002<\/p>\n<p>\u300ctype\u300d\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u4f7f\u3044\u300chttp:\/\/localhost\/getName.php\u300d\u3068\u3044\u3046\u30d7\u30ed\u30b0\u30e9\u30e0\u306b\u3001\u3069\u306e\u3088\u3046\u306a\u65b9\u6cd5\u3067\u30c7\u30fc\u30bf\u3092\u9001\u4fe1\u3059\u308b\u306e\u304b\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<p>\u300cPOST\u300d\u304b\u300cGET\u300d\u304b\u3067\u30c7\u30fc\u30bf\u306e\u53d7\u3051\u53d6\u308a\u5074\u3067\u3042\u308b\u300cgetName.php\u300d\u306e\u5185\u5bb9\u304c\u5909\u308f\u3063\u3066\u304d\u307e\u3059\u306e\u3067\u3001\u6ce8\u610f\u304c\u5fc5\u8981\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<h3>\u623b\u308a\u5024\u306f\u300cjson\u300d\u3067\u3088\u308d\u3057\u304f<\/h3>\n<p>\u300cdataType\u300d\u30aa\u30d7\u30b7\u30e7\u30f3\u3067\u306f\u3001\u30b5\u30fc\u30d0\u30fc\u5074\u3067\u51e6\u7406\u3055\u308c\u305f\u7d50\u679c\u3092\u3001JavaScript\u5074\u3067\u306f\u3069\u3046\u3044\u3063\u305f\u5f62\u5f0f\u3067\u53d7\u3051\u53d6\u308b\u306e\u304b\u3068\u3044\u3046\u6307\u5b9a\u3092\u3057\u307e\u3059\u3002<\/p>\n<p>\u3088\u304f\u4f7f\u308f\u308c\u308b\u306e\u306f\u300cjson\u300d\u5f62\u5f0f\u3067\u306e\u53d7\u3051\u53d6\u308a\u3067\u3059\u3002<\/p>\n<p>\u305d\u306e\u4ed6\u306b\u300ctext\u300d\u5f62\u5f0f\u3067\u306e\u53d7\u53d6\u3084\u300chtml\u300d\u3001\u300cxml\u300d\u306a\u3069\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<p>\u6307\u5b9a\u304c\u306a\u3051\u308c\u3070\u3001\u81ea\u52d5\u3067\u63a8\u6e2c\u3057\u3066\u304f\u308c\u307e\u3059\u304c\u3001\u671f\u5f85\u901a\u308a\u306e\u51e6\u7406\u304c\u884c\u308f\u308c\u306a\u3044\u5834\u5408\u3082\u3042\u308b\u306e\u3067\u3001\u660e\u793a\u3057\u3066\u304a\u304f\u306e\u304c\u6df7\u4e71\u304c\u306a\u304f\u3066\u3088\u3044\u3067\u3059\u3002<\/p>\n<h3>\u9001\u4fe1\u30c7\u30fc\u30bf\u3092\u8a2d\u5b9a\u3059\u308b<\/h3>\n<p>\u30c7\u30fc\u30bf\u306e\u9001\u308a\u5148\u3068\u3001\u30c7\u30fc\u30bf\u306e\u9001\u308b\u5f62\u5f0f\u304c\u6c7a\u307e\u308c\u3070\u3001\u6b21\u306b\u6c7a\u3081\u308b\u306e\u306f\u300c\u30c7\u30fc\u30bf\u306e\u5185\u5bb9\u300d\u3067\u3059\u3002<\/p>\n<p>\u30c7\u30fc\u30bf\u306f\u3001\u914d\u5217\u578b\u3067\u9001\u308a\u307e\u3059\u3002<\/p>\n<p>\u5f62\u5f0f\u306f\u300c\u30d8\u30c3\u30c0\u30fc\u540d : \u5024\u300d\u3068\u306a\u308a\u3001\u300c\u30d8\u30c3\u30c0\u30fc\u540d\u300d\u306f\u53d7\u3051\u53d6\u308a\u5074\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u6dfb\u5b57\u306b\u3082\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u4f8b\uff09date : {&#8216;user_id&#8217;: 21} \u2192 $_POST[&#8216;user_id&#8217;]<\/p>\n<p>\u4e0a\u8a18\u306e\u3088\u3046\u306bPHP\u306e\u300c$_POST\u300d\u306e\u6dfb\u5b57\u3068\u3057\u3066\u53d6\u5f97\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<h3>\u623b\u308a\u5024\u3092\u53d7\u3051\u53d6\u308d\u3046<\/h3>\n<p>\u30b5\u30fc\u30d0\u30fc\u5074\u3067\u51e6\u7406\u3055\u308c\u305f\u7d50\u679c\u3067\u300c\u6210\u529f\u300d\u3057\u3066\u3044\u308c\u3070\u3001\u300c.done(function (data)\u300d\u306e\u4e2d\u304c\u5b9f\u884c\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>\u300cdone(function()\u300d\u306e\u7b2c\uff11\u5f15\u6570\u300cdata\uff08\u4efb\u610f\u306e\u5909\u6570\u540d\uff09\u300d\u306f\u300c\u30b5\u30fc\u30d0\u30fc\u304b\u3089\u306e\u623b\u308a\u5024\u300d\u3067\u3059\u3002<\/p>\n<p>\u3053\u306e\u4e2d\u306b\u300cjson\u300d\u5f62\u5f0f\u306e\u30e6\u30fc\u30b6\u30fc\u540d\u304c\u4fdd\u5b58\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u300cdataType\u300d\u3067\u6307\u5b9a\u3057\u305f\u5f62\u5f0f\u3067\u3001\u623b\u3063\u3066\u304d\u305f\u5024\u3092\u5fc5\u8981\u306b\u5fdc\u3058\u305f\u5f62\u3067\u51e6\u7406\u3092\u3057\u307e\u3059\u3002<\/p>\n<p>Ajax\u3067\u306e\u7d50\u679c\u3092\u5143\u306b\u3057\u305f\u51e6\u7406\u306f\u3001\u3059\u3079\u3066\u300cdone\u300d\u5185\u3067\u884c\u3044\u307e\u3059\u3002<\/p>\n<h3>\u5931\u6557\u3057\u305f\u3068\u304d\u306e\u51e6\u7406\u3082\u5fd8\u308c\u305a\u306b<\/h3>\n<p>\u30b5\u30fc\u30d0\u30fc\u5074\u3067\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u305f\u6642\u306f\u300cdone\u300d\u304c\u51e6\u7406\u3055\u308c\u305a\u300cfail\u300d\u304c\u547c\u3073\u51fa\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>\u300cfail\u300d\u304c\u306a\u3051\u308c\u3070\u3001\u30a8\u30e9\u30fc\u767a\u751f\u6642\u306e\u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u5074\u306e\u51e6\u7406\u304c\u306a\u304f\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3059\u3002<\/p>\n<p>\u300cconsole.log\u300d\u306a\u3069\u3067\u3001\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u3066\u3044\u308b\u3053\u3068\u3092\u628a\u63e1\u3067\u304d\u308b\u3088\u3046\u306a\u51e6\u7406\u3092\u8ffd\u52a0\u3059\u308b\u3068\u3001\u5bfe\u5fdc\u304c\u3057\u3084\u3057\u304f\u306a\u308a\u307e\u3059\u3002<\/p>\n<h2>\u307e\u3068\u3081<\/h2>\n<p>\u99c6\u3051\u8db3\u3067\u3001\u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9\u5074\u306eAjax\u306b\u3064\u3044\u3066\u3001\u3054\u7d39\u4ecb\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u6b21\u56de\u306f\u3001\u30b5\u30fc\u30d0\u30fc\u5074\u3067\u52d5\u4f5c\u3059\u308b\u300cgetName.php\u300d\u90e8\u5206\u3092\u3054\u7d39\u4ecb\u3057\u3066Ajax\u51e6\u7406\u306e\u5168\u4f53\u3092\u4f5c\u3063\u3066\u3044\u304d\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3053\u3093\u306b\u3061\u306f\u3001Web\u30d7\u30ed\u30b0\u30e9\u30de\u306e\u7be0\u7530\u3067\u3059\u3002 \u5927\u962a\u3067\u306f\u307e\u3060\u6b8b\u6691\u304c\u6b8b\u308a\u3001\u65e5&#46;&#46;&#46;<\/p>\n","protected":false},"author":5,"featured_media":2137,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[45,16],"tags":[],"aioseo_notices":[],"_links":{"self":[{"href":"http:\/\/test.alaki.co.jp\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2133"}],"collection":[{"href":"http:\/\/test.alaki.co.jp\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/test.alaki.co.jp\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/test.alaki.co.jp\/blog\/index.php?rest_route=\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"http:\/\/test.alaki.co.jp\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2133"}],"version-history":[{"count":4,"href":"http:\/\/test.alaki.co.jp\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2133\/revisions"}],"predecessor-version":[{"id":4084,"href":"http:\/\/test.alaki.co.jp\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2133\/revisions\/4084"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/test.alaki.co.jp\/blog\/index.php?rest_route=\/wp\/v2\/media\/2137"}],"wp:attachment":[{"href":"http:\/\/test.alaki.co.jp\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2133"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/test.alaki.co.jp\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2133"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/test.alaki.co.jp\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2133"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}